Closed ageelg-mobile closed 10 years ago
Setting the current item on the ViewPager
is supposed to work.
Perhaps you can post more code so it might be possible to identify the reason for this behaviour.
Do you invoke the setCurrentItem()
method also in other parts of your app?
@ageelg-mobile I have the exact same problem..Have you got any solution yet?
@csanonymus , I left it for a while and just tried it and its working fine, sorry guys I don't have the exact reason. It might be an Eclipse issue, I have been getting the GC out of memory problems a lot lately.
If you want to have a look at my code, see below, https://github.com/ageelg-mobile/testViewPagerWslider
Thanks.
In my app the problem is only with the tabs... The fragment that is in view is the good one but the underline in the tabs( sorry..I don't know how it's called :)) ) is in the wrong place..I set the currentItem to 1, which should show my second fragment, and it does, but the 3rd tab is underlined..And if I swipe to show the fragment in the left, the underline moves to the first tab..It's weird :))
That was my problem too. With currentItem set to 1, the pager would point to the correct home fragment but the SlidingTab would highlight the tab corresponding to item 2. Somehow its fixed for me now, take a look at the sample code that I shared. Hopefully u can figure it out.
Ok..I will..Thanks!
One more thing..Did you changed something in the library or only in your code?
I had to change a few things to import it into an eclipse project, but I didnt add any code. Also you might consider the below issue on the same lib, the guy says dont use short tab names !
The only solution that I found to be efficient is this one :
pager.setCurrentItem(0, true); Handler h = new Handler(); h.postDelayed(new Runnable() {
@Override
public void run() {
pager.setCurrentItem(1, true);
}
}, 100);
Put this code in onResume() and than the tabstrip is placed correctly.
Good day,
Thanks for the nice lib, I am incorporating it in my new project and I wanted to know how to set the starting tab, I have three tabs [ tab1 , Home , tab2 ] , I want it to start from middle "Home" tab and I have tried the below code but dosnt work ?
pager.setAdapter(adapter); pager.setCurrentItem(1);
setting Current item to zero makes the first tab selected, 1&2 makes the last tab selected where I want it to select the middle tab.
Regards.