public class AttributeActivity extends Activity implements GestureDetector.OnGestureListener{
private ListView listView;
private static final int FLIP_DISTANCE=80;
private GestureDetector detector;
List persons;
public void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.attribute_main);
detector=new GestureDetector(AttributeActivity.this,AttributeActivity.this);
Intent intent=getIntent();
Bundle data=intent.getExtras();
persons=(List)data.getSerializable("MainActivity_persons");
listView=(ListView)findViewById(R.id.listView_attribute_main);
PersonAdapter personAdapter=new PersonAdapter(AttributeActivity.this,R.layout.list_item,persons);
listView.setAdapter(personAdapter);
}
@Override
public boolean onTouchEvent(MotionEvent event) {
return detector.onTouchEvent(event);
}
@Override
public void onShowPress(MotionEvent e) {
}
@Override
public void onLongPress(MotionEvent e) {
}
@Override
public boolean onSingleTapUp(MotionEvent e) {
return false;
}
@Override
public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) {
return false;
}
@Override
public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
Toast.makeText(AttributeActivity.this, "onFling()", Toast.LENGTH_SHORT).show();
if(e2.getX()-e1.getX()>=FLIP_DISTANCE){
Intent intent=new Intent(AttributeActivity.this,MainActivity.class);
startActivity(intent);
return true;
}
return false;
}
@Override
public boolean onDown(MotionEvent e) {
return false;
}
}
滑了滑屏幕没反应 哪里有问题