Hi there, i would like to create a dot indicator t...
# android
k
Hi there, i would like to create a dot indicator to show the user on which layout they are currently right now. i want to make that the dot indicator changed position when the main button that trigger the layout change is clicked. i've seen multiple reference and library about dot indicator, and almost all of them was automatic or changed when user scrolls the layout. so i would like to know if is there a way to do this, but by clicking button as a trigger?(and button as in additional button, not by clicking the dot indicator) any help would be appreciated, thank you.
i've found about this method, but i wonder if this would work or maybe won't be too effective? some people say that this method not really a great solution, as i have to know exactly how many pages i will be using. in my situation i do know about how much pages i'll be using.
Copy code
viewPager.addOnPageChangeListener(new OnPageChangeListener() {
            @Override
            public void onPageSelected(int position) {

                switch (position) {
    case 0:
        img_page1.setImageResource(R.drawable.dot_selected);
        img_page2.setImageResource(R.drawable.dot);
        img_page3.setImageResource(R.drawable.dot);
        img_page4.setImageResource(R.drawable.dot);
        break;

    case 1:
        img_page1.setImageResource(R.drawable.dot);
        img_page2.setImageResource(R.drawable.dot_selected);
        img_page3.setImageResource(R.drawable.dot);
        img_page4.setImageResource(R.drawable.dot);
        break;

    case 2:
        img_page1.setImageResource(R.drawable.dot);
        img_page2.setImageResource(R.drawable.dot);
        img_page3.setImageResource(R.drawable.dot_selected);
        img_page4.setImageResource(R.drawable.dot);
        break;

    case 3:
        img_page1.setImageResource(R.drawable.dot);
        img_page2.setImageResource(R.drawable.dot);
        img_page3.setImageResource(R.drawable.dot);
        img_page4.setImageResource(R.drawable.dot_selected);
        break;

    default:
        break;
    }


            }

            @Override
            public void onPageScrolled(int arg0, float arg1, int arg2) {

            }

            @Override
            public void onPageScrollStateChanged(int arg0) {

            }
        });
o
You can create a method which will change your img_pageX views as you want..and you will call this method by button click of course
k
ok, so what i get from what you, i could use above code to implement the dots indicator by using button click?