如何捕获微调器上的对讲onClick

时间:2018-07-11 03:03:48

标签: android spinner accessibility

在微调器(How to capture onClick event in Android for a spinner)上捕获onClick事件的常规方法不会触发对讲用户的事件。 onKeyListener或onTouchListener均不会触发。任何想法如何实现这一目标?

2 个答案:

答案 0 :(得分:0)

 spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
        @Override
        public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {

        }

        @Override
        public void onNothingSelected(AdapterView<?> adapterView) {

        }
    });

答案 1 :(得分:0)

spinnerFundTransferSelectTo.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parentView, View selectedItemView, int position, long id) {
TextView selectedText = (TextView) parentView.getChildAt(0);
String text = mAccountsTo.get(position).getactType();
String talkBackText = " account number ending with " + mAccountsTo.get(position).getactType(); // mAccountsTo.get(position).getactType() is one value from array list
selectedText.setContentDescription(talkBackText);
}

@Override
public void onNothingSelected(AdapterView<?> parentView) {

}
}

获取textview的视图并分配给selectedText。之后,该视图setContentDescription