ScrollView与ListView的焦点问题,互相滑动互不影响

来源:互联网 发布:浙师大行知学院专业 编辑:程序博客网 时间:2024/05/10 10:22
//布局<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"    xmlns:tools="http://schemas.android.com/tools"    android:layout_width="match_parent"    android:layout_height="match_parent"    tools:context="${relativePackage}.${activityClass}"    android:id="@+id/scrollView" >        <LinearLayout             android:layout_width="fill_parent"            android:layout_height="fill_parent"            android:orientation="vertical">    <com.example.test_listview.MyListView        android:id="@+id/mylist"        android:layout_width="fill_parent"        android:layout_height="fill_parent"        ></com.example.test_listview.MyListView>             <Button                 android:layout_width="wrap_content"                android:layout_height="wrap_content"                android:text="你猜猜"/>            <Button                 android:layout_width="wrap_content"                android:layout_height="wrap_content"                android:text="你猜猜"/>            <Button                 android:layout_width="wrap_content"                android:layout_height="wrap_content"                android:text="你猜猜"/>            <Button                 android:layout_width="wrap_content"                android:layout_height="wrap_content"                android:text="你猜猜"/>            <Button                 android:layout_width="wrap_content"                android:layout_height="wrap_content"                android:text="你猜猜"/>            <Button                 android:layout_width="wrap_content"                android:layout_height="wrap_content"                android:text="你猜猜"/>            <Button                 android:layout_width="wrap_content"                android:layout_height="wrap_content"                android:text="你猜猜"/>            <Button                 android:layout_width="wrap_content"                android:layout_height="wrap_content"                android:text="你猜猜"/>            <Button                 android:layout_width="wrap_content"                android:layout_height="wrap_content"                android:text="你猜猜"/>            <Button                 android:layout_width="wrap_content"                android:layout_height="wrap_content"                android:text="你猜猜"/>            </LinearLayout>   </ScrollView>
//代码ScrollView  scrollView=(ScrollView) findViewById(R.id.scrollView);listview.setOnTouchListener(new OnTouchListener(){                      @Override            public boolean onTouch(View v, MotionEvent event) {                // TODO Auto-generated method stub                if(event.getAction()==MotionEvent.ACTION_UP){                    scrollView.requestDisallowInterceptTouchEvent(false);                }else{                    scrollView.requestDisallowInterceptTouchEvent(true);                }                return false;            }        });
0 0
原创粉丝点击