android - PagerAdapter returns wrong position for Multi View Pager -


i implementing caurosel view pager adjusting page margin. able implement below

enter image description here

but facing problem pageradapter

@override public object instantiateitem(viewgroup container, int position) {     view view= inflater.inflate(r.layout.mylayout, null);      //      button btn=(button)view.findviewbyid(r.id.button1);     btn.settag(position);     btn.setonclicklistener(new view.onclicklistener() {         @override         public void onclick(view v) {           log.e("position",v.gettag()+"");        }    }     return imgview; } 

though setting tags, able correct position center page (selected item), when click on left side page's button returns wrong value.

i have searched issue lot, not find solution far.

looking help.

thanks

you can use recyclerview

linearlayoutmanager layoutmanager = ... recyclerview.setlayoutmanager(layoutmanager);  //when want horizontal layoutmanager.setorientation(context,linearlayoutmanager.horizontal,false);  //when want vertical layoutmanager.setorientation(context,linearlayoutmanager.vertical,false); 

Comments

Popular posts from this blog

mysql - Dreamhost PyCharm Django Python 3 Launching a Site -

java - Sending SMS with SMSLib and Web Services -

java - How to resolve The method toString() in the type Object is not applicable for the arguments (InputStream) -