Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

android some issue with viewpagerindicator

I am trying to implement viewpagerindicator within my app.

I am using viewpagerindicator lib. and my code is bellow link.

http://pastebin.com/TRUazPmb

I am getting an error,

11-15 13:07:35.145: E/AndroidRuntime(431): Caused by: java.lang.IllegalStateException: ViewPager adapter must implement TitleProvider to be used with TitlePageIndicator.

at ViewPageActivitys line indicator.setViewPager(mPager);

Anybody help me how to solve it?

Thank you

like image 839
Jyosna Avatar asked Dec 01 '25 21:12

Jyosna


1 Answers

public class ViewPageFragmentAdapter extends FragmentPagerAdapter {

replace this line with

public class ViewPageFragmentAdapter extends FragmentPagerAdapter implements TitleProvider{

You have to implement TitleProvider for your pager adapter if you are using titlePageindicator. you might need to add some functions after implementing this...

to call different children..

@Override
        public Fragment getItem(int arg0) {
            if (arg0 == 0) {
                return new Fragment1();
            } else if (arg0 == 1) {
                return new Fragment2();
            } else if (arg0 == 2){
                return new Fragment3();
            } else {
                return new Fragment0();
            }
        }
like image 176
Yashwanth Kumar Avatar answered Dec 03 '25 10:12

Yashwanth Kumar



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!