Android ListViewItem在片段中不可单击

Android ListViewItem在片段中不可单击,android,listview,android-fragments,Android,Listview,Android Fragments,我知道这个问题有几个答案,但没有一个对我有效。我试图在一个片段中创建一个带有自定义适配器的ListView,但这些项不可单击。这是我的听众: @Override public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) { Log.d("Klick", "Klick"); HeroItem heroItem = (HeroItem) her

我知道这个问题有几个答案,但没有一个对我有效。我试图在一个片段中创建一个带有自定义适配器的ListView,但这些项不可单击。这是我的听众:

    @Override
    public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
        Log.d("Klick", "Klick");
        HeroItem heroItem = (HeroItem) heroSelect.getItemAtPosition(i);
        int id = heroItem.id;
        FragmentManager fragmentManager = getFragmentManager();
        Fragment fragment = HeroDetailFragment.newInstance(String.valueOf(id));
        fragmentManager.beginTransaction().replace(R.id.content_selecthero, fragment, null).addToBackStack(null).commit();
    }
以下是项目的XML:

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent" android:layout_height="wrap_content"
    android:background="@color/colorPrimary"
    android:descendantFocusability="blocksDescendants">

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="100dp"
        android:id="@+id/itemList"
        android:descendantFocusability="blocksDescendants">

        <ImageView
            android:layout_height="60dp"
            app:srcCompat="@mipmap/ic_launcher"
            android:id="@+id/heroselect_avatar"
            android:layout_centerVertical="true"
            android:layout_alignParentLeft="true"
            android:layout_alignParentStart="true"
            android:layout_marginLeft="14dp"
            android:layout_marginStart="14dp"
            android:scaleType="fitCenter"
            android:layout_width="60dp"
            android:focusableInTouchMode="false"
            android:clickable="false"
            android:focusable="false"/>

        <TextView
            android:text="TextView"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerVertical="true"
            android:layout_toRightOf="@+id/heroselect_avatar"
            android:layout_toEndOf="@+id/heroselect_avatar"
            android:layout_marginLeft="65dp"
            android:layout_marginStart="65dp"
            android:id="@+id/heroselect_name"
            android:textColor="@color/colorWhite"
            android:textSize="30sp"
            android:focusableInTouchMode="false"
            android:clickable="false"
            android:focusable="false"/>
    </RelativeLayout>
</FrameLayout>

还有一个片段:

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="io.rocketfox.overwatchinfo.HeroSelectFragment"
android:background="@color/colorPrimary"
android:id="@+id/content_selecthero">

<ListView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:id="@+id/list_view_heroes" />


点击一个项目只是没有触发任何东西,经过几个小时的努力,我想问你们所有人!提前感谢:)

删除
heroSelect.setClickable(true)从代码中删除。

删除这行代码,然后选择。可设置可单击(true);检查一下。哇,真管用……谢谢!
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="io.rocketfox.overwatchinfo.HeroSelectFragment"
android:background="@color/colorPrimary"
android:id="@+id/content_selecthero">

<ListView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:id="@+id/list_view_heroes" />