我的应用支持ADA合规性。为此,我添加了
android:focusable="true"
自定义ListView
项的属性(3-4 TextViews)。但在此之后我的ListView
项目点击事件无效。当我从列表项中删除上面的属性时,它工作正常。但是对于ADA合规性,我需要这个。我该如何解决这个问题?
编辑:
<TextView
android:id="@+id/name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:nextFocusForward="@+id/city"
android:text="****"
android:focusable="true"
android:textColor="@android:color/black"
android:textStyle="bold" />
<TextView
android:id="@+id/city"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:nextFocusForward="@+id/address"
android:text="5145 N"
android:focusable="true"
android:textColor="@android:color/black" />
<TextView
android:id="@+id/address"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TX 78731"
android:focusable="true"
android:textColor="@android:color/black" />
</LinearLayout>
答案 0 :(得分:1)
您可以从代码中删除上一行,并将android:clickable="false"
和android:focusable="false"
添加到您的所有文本视图中,这样您的文字视图就不会有焦点和点击次数,因此您的项目点击将有效。
答案 1 :(得分:1)
在您的充气机布局的textview中添加:
android:focusable="false"
android:focusableInTouchMode="false"
并且在充气机的父布局中,即在充气机的相对布局中添加:
android:descendantFocusability="blocksDescendants"