FindPeopleFragment类型的onTouchEvent(MotionEvent)方法必须覆盖或实现超类型方法。 有没有办法解决它,而不是删除@Override,因为我怀疑删除它是导致GestureDetector不工作的原因。
public class FindPeopleFragment extends Fragment实现OnGestureListener {
private GestureDetector gDetector;
ImageView iv1;
public FindPeopleFragment(){}
@SuppressWarnings("deprecation")
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_find_people, container, false);
gDetector = new GestureDetector(this);
iv1=(ImageView)rootView.findViewById(R.id.imageView1);
return rootView;
}
@Override
public boolean onTouchEvent(MotionEvent me) {
return gDetector.onTouchEvent(me);
}
@Override
public boolean onDown(MotionEvent arg0) {
// TODO Auto-generated method stub
return false;
}
@Override
public boolean onFling(MotionEvent start, MotionEvent finish, float xVelocity, float yVelocity) {
if (start.getRawY() < finish.getRawY()) {
Log.i("fling", "if");
//((ImageView)findViewById(R.id.image_place_holder)).setImageResource(R.drawable.down);
//startActivity(new Intent(getActivity(),MainActivity.class));
} else {
Log.i("fling", "else");
//((ImageView)findViewById(R.id.image_place_holder)).setImageResource(R.drawable.up);
//startActivity(new Intent(getActivity(),Secc.class));
}
return true;
}
@Override
public void onLongPress(MotionEvent arg0) {
// TODO Auto-generated method stub
}
@Override
public boolean onScroll(MotionEvent arg0, MotionEvent arg1, float arg2,
float arg3) {
// TODO Auto-generated method stub
return false;
}
@Override
public void onShowPress(MotionEvent arg0) {
// TODO Auto-generated method stub
}
@Override
public boolean onSingleTapUp(MotionEvent arg0) {
// TODO Auto-generated method stub
return false;
}
}