我需要为RecyclerView添加辅助功能。我的RecyclerView中有7个项目,我希望TalkBack可以一次性读取它们所有。
这是我的RecyclerView小部件,请给予建议。属性 importantforaccessibility="yes"
没有起到帮助作用。
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="16dp"
android:layout_marginTop="24dp"
android:layout_marginRight="16dp"
android:orientation="vertical"
android:paddingBottom="16dp">
<TextView
android:id="@+id/txt_section"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="left"
/>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recycler_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:nestedScrollingEnabled="false"
android:orientation="vertical"
android:importantForAccessibility="yes"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" />
回收站适配器视图如下:
class ExitRowAgreementAdapter(val items: List<String>, val context: Context) :
RecyclerView.Adapter<ExitRowAgreementAdapter.ExitRowViewHolder>() {
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ExitRowViewHolder {
return ExitRowViewHolder(
LayoutInflater.from(context).inflate(
R.layout.row_items,
parent,
false
)
)
}
override fun getItemCount(): Int {
return items.size
}
override fun onBindViewHolder(holder: ExitRowViewHolder, position: Int) {
holder.txtExitRowItem.text = items.get(position)
}
inner class ExitRowViewHolder(view: View) : RecyclerView.ViewHolder(view) {
val txtExitRowItem = view.txt_exit_row_item
}
}