slider - View Pager in android with View Pager indicator Click Event? -
i using this sample code , library .this library working fine swipe screen want when click view pager indicator slide working position.
note:
this view pager indicator click working in android phone home page.
you have set on view of viewpager, this,
public class viewpageradapter extends pageradapter { context context; string[] title; string[] image; layoutinflater inflater; arraylist<categories> arraylist; activity activity; public viewpageradapter(context context, arraylist<categories> arraylist) { this.context = context; this.arraylist = arraylist; } @override public int getcount() { // todo auto-generated method stub return arraylist.size(); } @override public boolean isviewfromobject(view view, object object) { // todo auto-generated method stub return view == ((relativelayout) object); } @override public object instantiateitem(viewgroup container, final int position) { // todo auto-generated method stub textview txttitle; imageview image; inflater = (layoutinflater) context .getsystemservice(context.layout_inflater_service); view itemview = inflater.inflate(r.layout.item, container, false); itemview.setonclicklistener(new onclicklistener() { @override public void onclick(view v) { // todo auto-generated method stub intent = new intent(context, listviewactivity.class); bundle b = new bundle(); final string id = arraylist.get(position).getid(); b.putstring("id", id); i.putextras(b); context.startactivity(i); } }); txttitle = (textview) itemview.findviewbyid(r.id.tvname); image = (imageview) itemview.findviewbyid(r.id.imageview1); txttitle.settext(arraylist.get(position).gettitle()); ((viewpager) container).addview(itemview); ion.with(context).load(arraylist.get(position).getimage()).withbitmap() .resize(512, 512).centercrop().intoimageview(image); return itemview; } @override public void destroyitem(view container, int position, object object) { ((viewpager) container).removeview((view) object); } }
try this... works me.
Comments
Post a Comment