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