我有一个带有自定义适配器的 ListView,它使用 EditText 和 TextView 填充项目:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:id="@+id/et_choice_prob"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="numberSigned"/>
<TextView
android:id="@+id/tv_choice_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/et_choice_prob"
android:layout_alignBaseline="@id/et_choice_prob"
android:layout_marginLeft="5dip"
/>
</RelativeLayout>
如果我想设置一个 OnItemClickListener
它永远不会被调用,因为 EditText 窃取了焦点。
另一个线程提到我应该将 focusable
设置为 false
,这将移除实际编辑 TextView 的能力。
我还尝试将 ListView
的 descendantFocusability
设置为任何可用选项,但没有成功。
适配器没有做任何花哨的事情,但我会根据要求提供源代码。其他一切都以相同的方式在另一个 ListFragment
上完成并且有效。
最佳答案
尝试在您的 EditText
标签中添加此代码
android:focusable="true"
android:focusableInTouchMode="true"
关于android - 带有 EditText 和 OnItemClickListener 的 ListView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38785958/