1

我有一个ListView包含. 我的应用程序允许用户长按(通过in ,而不是通过on )的每一行,但它不是以默认方式设置动画。取而代之的是,它看起来像是按住。就像这样:AdapterRadioButtonListViewOnLongClickListenerAdapterOnItemLongClickListenerListViewRadioButton

在此处输入图像描述

但我想在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返回trueor false,但它没有改变任何东西。另一个想法是设置styles.xml,但我完全不知道如何设置。

有人可以清楚地告诉我一步一步解释如何实现我的目标吗?我的最小 API 是 15(Android 4.1)。

4

0 回答 0