最初に、要素を説明する内容の説明と、要素とやりとりする方法を説明する使用方法のヒントを分けることから始めます。
ViewGroupに明示的なコンテンツの説明がない場合、そのViewGroupの子の説明を照合して説明を推測しようとします。
You は、ViewGroupの明示的なコンテンツの説明を設定する必要があります。 I advocate going further and making the children inaccessible directly。
この動作では、完全なコントロールがあり、将来のレイアウトの変更には、ViewGroupのコンテンツ記述の副作用も含まれないことになります。 R.string.viewgroup_selected
はに解決する文字列リソースである
public class SelectStateDescribingLinearLayout extends LinearLayout {
public SelectStateDescribing(Context context, AttributeSet attrs) {
super(context, attrs);
}
@Override
public CharSequence getContentDescription() {
CharSequence contentDescription = super.getContentDescription();
return isSelected() ? appendSelectedTo(contentDescription) : contentDescription;
}
private String appendSelectedTo(CharSequence contentDescription) {
return getResources().getString(R.string.viewgroup_selected, contentDescription);
}
}
:選択した状態を追加する
一つの方法は、カスタムのViewGroup使用することを選択し、使用のヒントについて<string name="viewgroup_selected">%1$s selected</string>
(「ダブルタップを/選択解除」)、アクセシビリティデリゲートを使用できます。これはquestion has been answered hereです。