Android refresh image in viewpager -


i developing application show images using viewpager. in app, have 5 pages , each page showing 1 image. , have button can refresh 5 pages (means images different). here code:

imageadapter.java

public class imageadapter extends pageradapter {     private context context;     private list<integer> todayimage;      imageadapter(context context, list<integer> todayimage) {         this.context = context;         this.todayimage = todayimage;     }      public void setimage(list<integer> todayimage) {         this.todayimage = todayimage;     }      @override     public int getcount() {         return todayimage.size();     }      @override     public boolean isviewfromobject(view view, object object) {         return view == ((imageview) object);     }      @override     public object instantiateitem(viewgroup container, int position) {         imageview imageview = new imageview(context);         file imgfile = new file("data/data/com.project.project/"                 + todayimage.get(position) + ".jpg");         bitmap shufflebit = bitmapfactory.decodefile(imgfile.getabsolutepath());         imageview.setimagebitmap(shufflebit);         ((viewpager) container).addview(imageview, 0);         return imageview;     }      @override     public void destroyitem(viewgroup container, int position, object object) {         ((viewpager) container).removeview((imageview) object);     }      @override     public int getitemposition(object object) {         return position_none;     }      @override     public void destroyitem(view collection, int position, object view) {         ((viewpager) collection).removeview((view) view);     }  } 

this button use renew images:

shuffle.setonclicklistener(new onclicklistener() {     public void onclick(view v) {         adapter.setimage(newimage); }); 

this logcat:

05-03 01:17:50.793: e/androidruntime(716): fatal exception: main 05-03 01:17:50.793: e/androidruntime(716): java.lang.nullpointerexception 05-03 01:17:50.793: e/androidruntime(716):  @ com.example.project.main$1.onclick(main.java:201) 05-03 01:17:50.793: e/androidruntime(716):  @ android.view.view.performclick(view.java:4084) 05-03 01:17:50.793: e/androidruntime(716):  @ android.view.view$performclick.run(view.java:16966) 05-03 01:17:50.793: e/androidruntime(716):  @ android.os.handler.handlecallback(handler.java:615) 05-03 01:17:50.793: e/androidruntime(716):  @ android.os.handler.dispatchmessage(handler.java:92) 05-03 01:17:50.793: e/androidruntime(716):  @ android.os.looper.loop(looper.java:137) 05-03 01:17:50.793: e/androidruntime(716):  @ android.app.activitythread.main(activitythread.java:4745) 05-03 01:17:50.793: e/androidruntime(716):  @ java.lang.reflect.method.invokenative(native method) 05-03 01:17:50.793: e/androidruntime(716):  @ java.lang.reflect.method.invoke(method.java:511) 05-03 01:17:50.793: e/androidruntime(716):  @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:786) 05-03 01:17:50.793: e/androidruntime(716):  @ com.android.internal.os.zygoteinit.main(zygoteinit.java:553) 05-03 01:17:50.793: e/androidruntime(716):  @ dalvik.system.nativestart.main(native method) 

the app crashes when press button, can me how fix it? found answer using settag(), have no idea how it.


Comments

Popular posts from this blog

Eclipse formatter for java ending braces -

ruby - Nesting modules inside of a Rails eninge gem -

php - Why I am getting the Error "Commands out of sync; you can't run this command now" -