7

I have done Gallery View

gallery = (Gallery) findViewById(R.id.gallery1);
    MyAdapter adapter = new MyAdapter(this);
    gallery.setAdapter(adapter);
    gallery.setOnItemClickListener(new OnItemClickListener() {
        public void onItemClick(AdapterView<?> parent, View v,
                int position, long id) {
            Intent go = new Intent(Department2.this,
                    tablistclass_item.class);
            if (!larg) {

                go = new Intent(Department2.this, ListClass.class);
            }

            Bundle b = new Bundle();
            b.putString("headername", nameofimage[position]);
            b.putString("whichclass", "department");
            go.putExtras(b);
            startActivity(go);
        }
    });
}

Now how to make page indicator for Gallery view

hello_there_andy
  • 2,039
  • 2
  • 21
  • 51
Android Developer
  • 987
  • 1
  • 8
  • 22

2 Answers2

1

Constructing an indicator using a Gallery is difficult since you have no reliable way of knowing the index of the item that is currently at the center. Gallery has also been deprecated since API 16.

Instead you can use a ViewPager. It is available through the Android support library for older versions of Android as well.

You can use Jake Wharton's ViewPager Indicator in conjunction with this to get many kinds of indicators for your ViewPager or you can just have a look at the source code and construct your own.

Community
  • 1
  • 1
Anup Cowkur
  • 20,443
  • 6
  • 51
  • 84
0

Just add images according to your page position Like make a active image and other inactive images based on your page position. You can add the images dynamically.

Qantas 94 Heavy
  • 15,750
  • 31
  • 68
  • 83
Abhijit Chakra
  • 3,201
  • 37
  • 66