0

次のレイアウトで定義されたリスト項目を含む単純なリスト ビューがあります。

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/list_item_selector" >

    <TextView
        android:id="@+id/menuItemTextView"
        android:clickable="false"
        android:focusable="false"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true"
        android:background="#00000000"
        android:padding="20dp"
        android:textAppearance="?android:attr/textAppearanceMedium"
        android:textColor="@color/blue"
        android:textIsSelectable="true" />

    <ImageView
        android:id="@+id/arrow"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:layout_centerVertical="true"
        android:paddingRight="10dp"
        android:src="@drawable/arrow" />

> </RelativeLayout>

クリックTextViewlistView.onItemClickListenerても呼び出されません。問題は Android 4 で発生します。Android 2.x は問題ありません。TextViewで定義せずTextViewにイベントを渡すトリックはありますか?ListViewonClickListner

4

3 に答える 3

0

あなたの主な活動では、リストビューをフォーカス可能なものにするだけです。これは私にとってはうまくいきました。カスタム リスト ビューを使用している場合、フォーカスはリストではなくその子に渡されるため、フォーカスをリストビューに戻すには listView.focusable(true); を使用します。textview などの他のものは、フォーカスを false に設定するだけです。

于 2013-05-31T11:18:24.783 に答える
0

android:inputType="textMultiLine"もこの問題を引き起こす可能性があります。TextViewその属性をxml に含めている場合は、削除してみてください。

于 2015-06-01T05:50:23.370 に答える
0

それは android:textIsSelectable="true" 属性でした。やみくもにリントのヒントに従わないでください。

于 2013-06-18T09:06:35.837 に答える