【问题标题】:Android: how to avoid the pressed visual of a button in a listview item when pressing the list itemAndroid:如何在按下列表项时避免在列表视图项中按下按钮的视觉效果
【发布时间】:2011-11-24 02:29:49
【问题描述】:

我有一个列表视图,每个列表项中都有一个按钮。当我按下列表项时,我发现里面的按钮也显示了点击的视觉效果。如何防止在按下列表项时单击按钮的这种视觉效果?

这是列表项的布局:

<?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>

【问题讨论】:

  • 我有同样的问题,但我不知道如何使用接受的答案来解决它。您能否提供更多详细信息,您是如何解决的?

标签: android listview button listitem


【解决方案1】:

listviewonItemClickListener(...) 中,您可以暂时禁用按钮的点击。但不要忘记在选择其他项目时重新启用它。我还没有尝试过,但它可能会起作用。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-01-02
    • 1970-01-01
    • 2015-08-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多