我有一个 ListView ,每个列表项中都有一个按钮。当我按下列表项时,我发现里面的按钮也显示了点击的视觉效果。按下列表项时如何防止单击按钮的这种视觉效果?
这是列表项的布局:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="50dp"
android:background="#DFDEDF" >
<ImageView
android:id="@+id/LocationImageView"
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_weight="0"
android:src="@drawable/icn_location_yellow_30x30"
android:layout_gravity="center_vertical"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp" />
<TextView
android:id="@+id/LocationTitleTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_gravity="center_vertical"
android:ellipsize="end"
android:fadingEdge="horizontal"
android:singleLine="true"
android:textColor="@android:color/black" />
<Button
android:id="@+id/LocationDetailButton"
android:layout_width="21dp"
android:layout_height="21dp"
android:layout_weight="0"
android:background="@drawable/arrow_btn"
android:layout_gravity="center_vertical"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:focusable="false"
android:focusableInTouchMode="false" />
</LinearLayout>
最佳答案
在 listview
的 onItemClickListener(...)
中,您可以暂时禁用按钮的点击。但不要忘记在选择其他项目时重新启用它.我没试过这个,但它可能有用。
关于Android:如何在按下列表项时避免按下 ListView 项中按钮的视觉效果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8251578/