android - Add imageview inside one slide in a viewpager, how to attach the image to right viewgroup -



android - Add imageview inside one slide in a viewpager, how to attach the image to right viewgroup -

i have navigation drawer , viewpager 1 can chose object list in drawer. when clicked/ touched want add together image active slide in viewpager.

i have made method addobjecttoslide() that, image attached wrong view. when slide 1 page another, image stuck on top. when open drawer, image on that.

here code:

private void addobjecttoslide(int pagenumber, int position) { viewgroup rootview = (viewgroup) findviewbyid(r.id.scroll_view_slides).getrootview(); relativelayout.layoutparams imparams = new relativelayout.layoutparams(relativelayout.layoutparams.wrap_content, relativelayout.layoutparams.wrap_content); imparams.addrule(relativelayout.center_in_parent, relativelayout.true); imageview iv = new imageview(rootview.getcontext()); switch (pagenumber) { case 0 : iv.setimagedrawable(getresources().obtaintypedarray(r.array.p1_object).getdrawable(position)); break; default: // add together later } rootview.addview(iv, imparams); }

scroll_view_slides relativelayout id fragment_screen_slide_page.xml.

i found solution, changed next sentences:

viewgroup rootview = (viewgroup) mviewpager.findviewwithtag(pagenumber);

after reading question , solutions.

android android-viewpager

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -