I have a listview which gets assigned with different datasets dynamically. This works fine. I have also made fastScrollEnabled to be true. For the sectionIndexer to be updated I need to call
list.setFastScrollEnabled(false);
list.setFastScrollEnabled(true);
The problem is the index shows in top left and this is a know issue. As a work-around whenever I change the orientation the index is again correctly shown. To test this I have implemented a custom ListView and the observation is if I can force listView to call onSizeChanged() it will show up properly.
Now the question:
Is it possible to force listView to call onSizeChanged() method? If yes how can we accomplish this.
Does anyone know of conditions when onSizeChanged() is called. It is definitely called when the orientation changes, any other conditions we can think of.
To force onSizeChanged on ListView I do the following:
myList.getLayoutParams().height = myList.getHeight() + 1;
myList.requestLayout();
Just be sure to not call +1 or -1 everytime as the list may just overstretch the size specified and hence use a flag to toggle between +1 and -1.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With