TabLayout/Pizza >> How to guess the delay time?


#1

Hi,

In TabLayout/Pizza sample app, how do we guess how much time it would take for setCurrentItem() to affect ViewPager and MaterialTabs objects? In this case, 100ms has been taken in postDelayed(). Can it be used generically?

Thanks!


#2

how do we guess how much time it would take for setCurrentItem() to affect ViewPager and MaterialTabs objects?

Well, ideally, you don’t do any of that. Using postDelayed() to get past problems like this is a hack. As I noted in the book, this code was a workaround for a bug in the library.

In terms of guessing, play with various values and see what works. Take into account the speed of your test device — if it is fast, then other devices might be slower and might need more time.

FWIW, this sample and all other uses of this library will be removed from the book in the next update.


#3

In terms of guessing, play with various values and see what works. Take into account the speed of your test device — if it is fast, then other devices might be slower and might need more time.

Thanks

FWIW, this sample and all other uses of this library will be removed from the book in the next update.

Would it be replaced by another library or be just removed for good>


#4

TabLayout is in the Design Support library, with an equivalent in CWAC-CrossPort. The only reason why I kept this sample in here after the release of CWAC-CrossPort was that a bunch of other samples used this particular tab implementation. I am rewriting all of those to use something else, typically the CWAC-CrossPort implementation.