在ScrollView 下實現listview的單獨滑動。

只需要很簡單的一句話就可以了:

                        listview.getParent().requestDisallowInterceptTouchEvent(true);

但是在具體代碼編寫中可以把這句話放在listview的OnTouchListener。

        View layoutView = inflater.inflate(R.layout.a_u010_i01_16, container, false);
        View listView = layoutView.findViewById(R.id.hennoMeterNoList);
        if (listView instanceof ListView) {
            final ListView listview = (ListView) listView;
            listview.setOnTouchListener(new View.OnTouchListener() {
                @Override
                public boolean onTouch(View view, MotionEvent motionevent) {
                    if (motionevent.getAction() == MotionEvent.ACTION_DOWN) {
                         listview.getParent().requestDisallowInterceptTouchEvent(true);
                    }
                    return false;
                }
            });
        }

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章