onFling()后按钮无法点击

时间:2014-12-07 17:23:33

标签: java android layout onclick onfling

我希望能够点击并在我的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 ButtonsClick功能已停止。有谁知道这是为什么?

Buttons位于swipeLayout,因此我将其OnTouchListener返回false。我想那是错的。如何使Buttons可点击并可刷卡?

0 个答案:

没有答案