我試圖在顯示小吃店後發送輔助功能。但沒有什麼可玩的。這裏是我的代碼是在調用onStart()的生命週期方法:無法在Android中發送輔助功能事件
final Snackbar snackbar = Snackbar
.make(findViewById(R.id.container), "snackbars are cool", Snackbar.LENGTH_INDEFINITE);
snackbar.setActionTextColor(getResources().getColor(R.color.snackbar_actions));
View snackbarView = snackbar.getView();
snackbarView.setBackgroundColor(Color.DKGRAY);
TextView textView = (TextView) snackbarView.findViewById(android.support.design.R.id.snackbar_text);
textView.setTextColor(Color.WHITE);
snackbar.show();
//time to send a accessibility event below
final ViewGroup parentView = (ViewGroup)findViewById(R.id.container);
if (parentView != null) {
final AccessibilityManager a11yManager =
(AccessibilityManager) this.getSystemService(Context.ACCESSIBILITY_SERVICE);
if (a11yManager != null && a11yManager.isEnabled()) {
final AccessibilityEvent e = AccessibilityEvent.obtain();
snackbarView.onInitializeAccessibilityEvent(e);
e.getText().add("some more text to say");
//nothing happens here
parentView.requestSendAccessibilityEvent(snackbarView, e);
}
}
沒有,因爲我希望它得到正確的儘快解僱作爲正在顯示的小吃吧是不。 – j2emanue