android - problems with listview using in viewpager? -


i want add single listview in 4 pages of viewpager different data each page. vector pages = new vector();

pages.add(listappstore1); pages.add(listappstore2); pages.add(listappstore3); pages.add(listappstore4);      viewpager vp = (viewpager) findviewbyid(r.id.viewpager);     custompageradapter adapter = new custompageradapter(appsactivity.this,pages);     vp.setadapter(adapter);      vp.setonpagechangelistener(new onpagechangelistener() {          public void onpageselected(int arg0) {             // todo auto-generated method stub          }          public void onpagescrolled(int arg0, float arg1, int position) {             // todo auto-generated method stub           }          public void onpagescrollstatechanged(int position1) {             // todo auto-generated method stub             if (position1==0) {                  modifydata();                                      myappstore.setadapter(mstoreadapter);             } else if (position1==1) {                 modifydata();                                      myappstore.setadapter(mstoreadapter);             }else if (position1==2) {                 modifydata();                                      myappstore.setadapter(mstoreadapter);             }else if (position1==3) {                       modifydata();                                      myappstore.setadapter(mstoreadapter);             }         }     });  } 

and here adapter class public class custompageradapter extends pageradapter {

 private context mcontext;  private vector<view> pages;   public custompageradapter(context context, vector<view> pages) {   this.mcontext=context;   this.pages=pages;  }   @override  public object instantiateitem(viewgroup container, int position) {     view page = pages.get(position);    container.addview(page);     return page;  }     @override  public int getcount() {   return 3;  }   @override  public boolean isviewfromobject(view view, object object) {   return view.equals(object);  }   @override  public void destroyitem(viewgroup container, int position, object object) {   container.removeview((view) object);  }  } 

i getting error in logcat after force close specified child has parent. must call removeview() on child's parent first. idea please!!!!! have changed 4 listview.... , showing 3 pages!!!where fouth one? , if pagerviewer holds 3 pages @ 1 time how remove first 1 on fourth position , vice versa????

you adding different views in same parent(container) in instantiateitem method..remove line instantiateitem()

 container.addview(page); 

Comments

Popular posts from this blog

java - activate/deactivate sonar maven plugin by profile? -

python - TypeError: can only concatenate tuple (not "float") to tuple -

java - What is the difference between String. and String.this. ? -