button - Progress Bar in android -
i have tried implement progressbar in application gets displayed when click on button plays sound.
i have done coding run time exception , application not starting. here posting code reference.
holder.imgplaybtn.setonclicklistener(new view.onclicklistener() { public void onclick(view v) { progressdialog progressdialog; onclicklistener mycontext = this; progressdialog = new progressdialog((context) mycontext); progressdialog.setprogressstyle(progressdialog.style_horizontal); progressdialog.setmessage("..."); progressdialog.setcancelable(false); } });
the logcat output :
12-02 12:19:58.268: error/androidruntime(392): java.lang.classcastexception: com.android.soundmachine.switch2datalist$soundmachineadapter$2 12-02 12:19:58.268: error/androidruntime(392): @ com.android.soundmachine.switch2datalist$soundmachineadapter$2.onclick(switch2datalist.java:1645) 12-02 12:19:58.268: error/androidruntime(392): @ android.view.view.performclick(view.java:2364) 12-02 12:19:58.268: error/androidruntime(392): @ android.view.view.ontouchevent(view.java:4179) 12-02 12:19:58.268: error/androidruntime(392): @ android.view.view.dispatchtouchevent(view.java:3709) 12-02 12:19:58.268: error/androidruntime(392): @ android.view.viewgroup.dispatchtouchevent(viewgroup.java:884) 12-02 12:19:58.268: error/androidruntime(392): @ android.view.viewgroup.dispatchtouchevent(viewgroup.java:884) 12-02 12:19:58.268: error/androidruntime(392): @ android.view.viewgroup.dispatchtouchevent(viewgroup.java:884) 12-02 12:19:58.268: error/androidruntime(392): @ android.view.viewgroup.dispatchtouchevent(viewgroup.java:884) 12-02 12:19:58.268: error/androidruntime(392): @ android.view.viewgroup.dispatchtouchevent(viewgroup.java:884) 12-02 12:19:58.268: error/androidruntime(392): @ android.view.viewgroup.dispatchtouchevent(viewgroup.java:884) 12-02 12:19:58.268: error/androidruntime(392): @ android.view.viewgroup.dispatchtouchevent(viewgroup.java:884) 12-02 12:19:58.268: error/androidruntime(392): @ com.android.internal.policy.impl.phonewindow$decorview.superdispatchtouchevent(phonewindow.java:1659) 12-02 12:19:58.268: error/androidruntime(392): @ com.android.internal.policy.impl.phonewindow.superdispatchtouchevent(phonewindow.java:1107) 12-02 12:19:58.268: error/androidruntime(392): @ android.app.activity.dispatchtouchevent(activity.java:2061) 12-02 12:19:58.268: error/androidruntime(392): @ com.android.internal.policy.impl.phonewindow$decorview.dispatchtouchevent(phonewindow.java:1643) 12-02 12:19:58.268: error/androidruntime(392): @ android.view.viewroot.handlemessage(viewroot.java:1691) 12-02 12:19:58.268: error/androidruntime(392): @ android.os.handler.dispatchmessage(handler.java:99) 12-02 12:19:58.268: error/androidruntime(392): @ android.os.looper.loop(looper.java:123) 12-02 12:19:58.268: error/androidruntime(392): @ android.app.activitythread.main(activitythread.java:4363) 12-02 12:19:58.268: error/androidruntime(392): @ java.lang.reflect.method.invokenative(native method) 12-02 12:19:58.268: error/androidruntime(392): @ java.lang.reflect.method.invoke(method.java:521) 12-02 12:19:58.268: error/androidruntime(392): @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:860) 12-02 12:19:58.268: error/androidruntime(392): @ com.android.internal.os.zygoteinit.main(zygoteinit.java:618) 12-02 12:19:58.268: error/androidruntime(392): @ dalvik.system.nativestart.main(native method) 12-02 12:19:58.287: info/process(52): sending signal. pid: 392 sig: 3 12-02 12:19:58.287: info/dalvikvm(392): threadid=7: reacting signal 3 12-02 12:19:58.287: error/dalvikvm(392): unable open stack trace file '/data/anr/traces.txt': permission denied 12-02 12:20:05.098: debug/dalvikvm(99): gc freed 2375 objects / 139384 bytes in 81ms 12-02 12:20:10.077: debug/dalvikvm(212): gc freed 43 objects / 2096 bytes in 58ms
can body please me?
thanks, david,
progressdialog = new progressdialog((context) mycontext); wrong, can use instead of it:
progressdialog = new progressdialog(v.getcontext());
and also, forgot call show()
method show progressbar dialog box, write below line @ end:
progressdialog.show();
Comments
Post a Comment