Adapter for circle page indicator in android

Posted by Charles LAU on Stack Overflow See other posts from Stack Overflow or by Charles LAU
Published on 2012-10-27T22:48:49Z Indexed on 2012/10/27 23:00 UTC
Read the original article Hit count: 278

Filed under:

I am currently working on an android application which have multiple pages. I am trying to use Circle page indicator to allow users view multiple pages by flipping over the screen. Each page has seperate XML file for the view and each page has a button which is bind to a java method in the Activity. I would like to know how to initalise all the buttons in the Activity for multiple pages. Because at the moment, I can only initalise the button for the first page of the views. I cannot initalise the button for second and third page. Does anyone know how to achieve this. I have placed all the jobs to be done for all the buttons in a single activity.

I am currently using this indicator : http://viewpagerindicator.com/

Here is my adapter for the circle page indicator:

 @Override
public Object instantiateItem(View collection, int position) {

    inflater = (LayoutInflater) collection.getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);

    int resid = 0;
    //View v = null;// inflater.inflate( R.layout.gaugescreen, (ViewPager)collection, false );
    switch( position )
    {
        case 0:
            resid = R.layout.gaugescreen;
            break;
        case 1:
            resid= R.layout.liveworkoutstatisticsscreen;
            break;
         case 2:
             resid = R.layout.mapscreen;
             break;
        default:
            resid = R.layout.gaugescreen;
            break;


    }


        View view = inflater.inflate(resid, null);

        ((ViewPager) collection).addView(view,0);

        return view;
}

Does anyone know how to achieve this?

Thanks for any help in advance

© Stack Overflow or respective owner

Related posts about android