I am new to android first of all so think of any newbie mistakes first
I am trying to add a fling function in my code.
public class MainGamePanel ext
For me I had to change the setLongClickable to true.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment, container, false);
view.setLongClickable(true); // <---- here
view.setOnTouchListener(getSwipeListener());
return view;
}
public OnTouchListener getSwipeListener() {
return new OnTouchListener() {
private GestureDetector gesture =
new GestureDetector(getActivity(),
new GestureDetector.SimpleOnGestureListener() {
@Override
public boolean onFling(MotionEvent e1,
MotionEvent e2,
float velocityX,
float velocityY) {
do some flinging here
return something
}
});
@Override
public boolean onTouch(View v, MotionEvent event) {
return gesture.onTouchEvent(event);
}
};
}