Reputation: 2092
I've got a ListView that's gets populated with data from the server (phone numbers) and I'm polling every 2 seconds. When TalkBack feature is switched on and the I tap on a list item, the talkBack doesn't get the chance to read the whole string because the refresh occurs and the talkBack starts from the begging. Is there a way to detect if the TalkBack if content description is being read? Thank you.
Upvotes: 2
Views: 809
Reputation: 24124
ListView
relies on the value of Adapter.hasStableIds()
to determine if inflated views can be reused across data set changes.
If this method returns false
, ListView assumes that there is no consistency between the data set before and after a change. As a result, it doesn't know where accessibility focus should be placed.
However, if this method returns true
and your adapter maintains a consistent mapping between item ID and data, then ListView is able to maintain accessibility focus on the correct item -- even if it changes position within the data set.
To fix this issue, you can modify your adapter to maintain stable IDs:
class MyAdapter extends ListAdapter {
...
@Override
public boolean hasStableIds() {
return true;
}
@Override
public long getItemId(int position) {
// Return a consistent mapping between the item at a given
// position and an arbitrary (but consistent!) ID associated
// with that item.
...
}
}
Upvotes: 2