setCurrentItem after setting adapter on GridViewPa

2019-08-06 01:45发布

问题:

does anyone knows a better solution then waiting for a few milliseconds if you try to start with a given item on a GridViewPager in Android Wear like this one:

pager.setAdapter(new MainGridAdapter(this, getFragmentManager()));
Runnable dirtyHack = new Runnable() {
    @Override
    public void run() {
        pager.setCurrentItem(2, 0);
    }
};
Handler handler = new Handler();
handler.postDelayed(dirtyHack, 100);

The issue is described here and I ran also into it