我有ListView
个自定义Adapter
,其中包含RadioButton
。我的应用允许用户长按ListView
的每一行(OnLongClickListener
中的Adapter
,而不是OnItemLongClickListener
上的ListView
),但不是以默认方式设置动画。而不是它,看起来像按住RadioButton
。完全是这样的:
但我希望在OnLongClickListener
期间突出显示完整行。
我的xml文件:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/languageitem_linear_main"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?android:attr/activatedBackgroundIndicator"
android:baselineAligned="false"
android:clickable="false"
android:descendantFocusability="blocksDescendants"
android:focusable="false"
android:orientation="horizontal"
android:padding="3dp" >
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="4"
android:orientation="vertical" >
<TextView
android:id="@+id/languageitem_text_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:focusableInTouchMode="false"
android:padding="3dp"
android:textSize="@dimen/drawer_list_name_text" />
<TextView
android:id="@+id/languageitem_text_count"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:focusableInTouchMode="false"
android:padding="3dp"
android:textSize="@dimen/adapter_day_calendar_date_text" />
<ProgressBar
android:id="@+id/languageitem_progress_downloading"
style="@style/Widget.AppCompat.ProgressBar.Horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:indeterminate="false"
android:padding="3dp"
android:visibility="invisible" />
</LinearLayout>
<RelativeLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:clickable="false" >
<ImageView
android:id="@+id/languageitem_image_update"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_gravity="center|center"
android:layout_margin="0dp"
android:contentDescription="@string/about_app"
android:padding="0dp"
android:src="@drawable/ic_autorenew_black_36dp" />
</RelativeLayout>
<RelativeLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1" >
<ImageView
android:id="@+id/languageitem_image_download"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_gravity="center|center"
android:layout_margin="0dp"
android:contentDescription="@string/about_app"
android:padding="0dp"
android:src="@drawable/ic_file_download_black_36dp" />
<RadioButton
android:id="@+id/languageitem_radiobutton_selected"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_gravity="center|center"
android:layout_margin="0dp"
android:checked="false"
android:clickable="false"
android:focusable="false"
android:focusableInTouchMode="false"
android:padding="0dp"
android:visibility="invisible" />
</RelativeLayout>
</LinearLayout>
我还尝试添加空OnItemLongClickListener
,返回true
或false
,但它没有改变任何内容。另一个想法是设置styles.xml
,但我完全不知道如何。
有人可以一步一步地告诉我如何实现我的目标吗?我的最小API为15(Android 4.1)。