android - ViewPager OnItemClickListener -
i'm new viewpager, , after reading http://developer.android.com/reference/android/support/v4/view/viewpager.html google, can't seem find related on viewpager.setonitemclicklistener(new onitemclicklistener() {
have other options act item clicked?
testing out
viewpager.setonitemclicklistener(new onitemclicklistener() { @override public void onitemclick(adapterview<?> parent, view view, int position, long id) { intent = new intent(mainactivity.this, singleitemview.class); i.putextra("flag", flag); i.putextra("position", position); startactivity(i); } });
error : method setonitemclicklistener(new adapterview.onitemclicklistener(){}) undefined type viewpager
there no onitemclick callback method viewpager. if want click events on each page you'll have build listener page content within adapter.
something this:
@override public object instantiateitem(view collection, final int pos) { //have make final can see inside of onclick() layoutinflater inflater = (layoutinflater) collection.getcontext() .getsystemservice(context.layout_inflater_service); view page = inflater.inflate(r.layout.your_page, null); page.setonclicklistener(new onclicklistener(){ public void onclick(view v){ //this log page number click log.i("tag", "this page clicked: " + pos); } }); ((viewpager) collection).addview(page, 0); return page; }
exactly need depend bit on else doing inside of instantiateitem()
haven't posted can't give more specific answer.
Comments
Post a Comment