Android view pager with page indicator

后端 未结 7 1482
终归单人心
终归单人心 2020-12-07 19:23

I need to get page indicator in the view pager file with images. Here is my code.

public class IndicatorActivity extends Activity {


 /** Called when the ac         


        
相关标签:
7条回答
  • 2020-12-07 19:57

    I have also used the SimpleViewPagerIndicator from @JROD. It also crashes as described by @manuelJ.

    According to his documentation:

    SimpleViewPagerIndicator pageIndicator = (SimpleViewPagerIndicator) findViewById(R.id.page_indicator);
    pageIndicator.setViewPager(pager);
    

    Make sure you add this line as well:

    pageIndicator.notifyDataSetChanged();
    

    It crashes with an array out of bounds exception because the SimpleViewPagerIndicator is not getting instantiated properly and the items are empty. Calling the notifyDataSetChanged results in all the values being set properly or rather reset properly.

    0 讨论(0)
提交回复
热议问题