Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/oop/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
android中的页面指示器_Android - Fatal编程技术网

android中的页面指示器

android中的页面指示器,android,Android,我已经完成了Gallery视图 gallery = (Gallery) findViewById(R.id.gallery1); MyAdapter adapter = new MyAdapter(this); gallery.setAdapter(adapter); gallery.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView&

我已经完成了
Gallery视图

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);
        }
    });
}
gallery=(gallery)findViewById(R.id.gallery1);
MyAdapter=新的MyAdapter(此);
gallery.setAdapter(适配器);
gallery.setOnItemClickListener(新的OnItemClickListener(){
public void onItemClick(AdapterView父视图、视图v、,
内部位置,长id){
意向go=新意向(部门2.1),
tablistclass_项目类别);
如果(!larg){
go=新意图(部门2.this,ListClass.class);
}
Bundle b=新Bundle();
b、 putString(“headername”,图像名称[位置]);
b、 putString(“whichclass”、“department”);
go.putExtras(b);
星触觉(go);
}
});
}

现在,如何为
图库视图制作
页面指示器

很难使用图库构建指示器,因为您无法可靠地知道当前位于中心的项目的索引。画廊也被关闭了

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);
        }
    });
}
相反,您可以使用。对于旧版本的Android,它也可以通过


您可以结合使用它来获取ViewPager的多种指示器,也可以查看源代码并构建自己的指示器。

只需根据页面位置添加图像,如根据页面位置生成活动图像和其他非活动图像。您可以动态添加图像。

请参阅