簡體   English   中英

將ACTION_UP onTouchListener滾動到子級后,GridView不會調用

[英]GridView after scroll the ACTION_UP onTouchListener to the child wont call

// getView()方法中GridView的子視圖。 似乎需要實現自定義GridView,以處理孩子的整個滾動和其他觸摸操作。 謝謝你的幫助。

class ViewHolder implements View.OnTouchListener {
    ImageView image;
    TextView text;
    int position;
    RelativeLayout root;

    public ViewHolder(View v, int position) {
        this.image = (ImageView) v.findViewById(R.id.grid_image);
        this.text = (TextView) v.findViewById(R.id.item_text);
        this.root = (RelativeLayout) v.findViewById(R.id.root_layout);
        this.position = position;
        image.setOnTouchListener(this);

    }


    @Override
    public boolean onTouch(View v, MotionEvent event) {

        switch (event.getActionMasked()) {
            case MotionEvent.ACTION_DOWN:
                Log.e("DOWN", "YES");
                return true;
            case MotionEvent.ACTION_MOVE:

                break;
            case MotionEvent.ACTION_UP:
                Log.e("UP", "YES");
                break;
        }
        return true;
    }


}

這是因為滾動時,觸摸事件會重新路由到網格視圖。 發生這種情況時,您會看到ACTION_CANCEL。 您需要考慮這一點。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM