我希望能够点击并在我的Buttons
上滑动。但是,一旦我实施了onFling
方法,我就无法点击Buttons
。有人知道如何解决这个问题吗?
这是我的代码:
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.game_activity);
GestureDetector gestureScanner = new GestureDetector(this);
OnTouchListener onTL = new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
// TODO Auto-generated method stub
gestureScanner.onTouchEvent(event);
return true;
}
};
//the Buttons are in the swipeLayout
swipeLayout = (LinearLayout) findViewById(R.id.ll_screen_bttns);
swipeLayout.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
// TODO Auto-generated method stub
gestureScanner.onTouchEvent(event);
return false;
}
});
//setting OnTouchListener for all my Buttons
for(Button b: button_list)
b.setOnTouchListener(onTL);
}
使用此代码后,我可以通过fling
Buttons
但Click
功能已停止。有谁知道这是为什么?
Buttons
位于swipeLayout
,因此我将其OnTouchListener返回false。我想那是错的。如何使Buttons
可点击并可刷卡?