I've a ListView
with a footer View
that contains a TextView
that can be changed dynamically according to the language selected.
When I select a different language I update my ListView
items:
mBaseAdapter.updateItems(items);
BaseAdapter:
public void updateItems(List<Map.Entry<Integer, String>> items) {
mItemsResIdList = new ArrayList<>(items);
notifyDataSetChanged();
}
And to update my footer I was doing this:
mListViewFooter.invalidate();
This didn't work, the text didn't change. However, it works if I replace the invalidate();
with:
((TextView)mListViewFooter.findViewById(R.id.myTextView)).setText(R.string.myCopy);
Note: my ListView
elements are TextViews
that are translated according to the language selected and they can also increase or decrease in number. My footer never changes, I just want a View
update so that the text gets translated (the correct value-(lang)/strings.xml gets picked).
My question is, why does the first approach doesn't work? The only explanation I can think of is that the invalidate();
does not invoke setText()
again, it only redraws the View
. It worked with the ListView
because the adapter calls getView()
again where the TextViews
are populated again. Is this assumption correct?
Thanks.