I have tried to implement the ProgressBar in my application that gets displayed when I click on the Button which plays the sound.
I have done the coding but I get the run time exception and the application is not starting.
Here I am posting my code for the 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 is :
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): at com.android.soundmachine.Switch2DataList$SoundMacHineAdapter$2.onClick(Switch2DataList.java:1645)
12-02 12:19:58.268: ERROR/AndroidRuntime(392): at android.view.View.performClick(View.java:2364)
12-02 12:19:58.268: ERROR/AndroidRuntime(392): at android.view.View.onTouchEvent(View.java:4179)
12-02 12:19:58.268: ERROR/AndroidRuntime(392): at android.view.View.dispatchTouchEvent(View.java:3709)
12-02 12:19:58.268: ERROR/AndroidRuntime(392): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
12-02 12:19:58.268: ERROR/AndroidRuntime(392): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
12-02 12:19:58.268: ERROR/AndroidRuntime(392): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
12-02 12:19:58.268: ERROR/AndroidRuntime(392): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
12-02 12:19:58.268: ERROR/AndroidRuntime(392): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
12-02 12:19:58.268: ERROR/AndroidRuntime(392): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
12-02 12:19:58.268: ERROR/AndroidRuntime(392): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
12-02 12:19:58.268: ERROR/AndroidRuntime(392): at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:1659)
12-02 12:19:58.268: ERROR/AndroidRuntime(392): at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1107)
12-02 12:19:58.268: ERROR/AndroidRuntime(392): at android.app.Activity.dispatchTouchEvent(Activity.java:2061)
12-02 12:19:58.268: ERROR/AndroidRuntime(392): at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1643)
12-02 12:19:58.268: ERROR/AndroidRuntime(392): at android.view.ViewRoot.handleMessage(ViewRoot.java:1691)
12-02 12:19:58.268: ERROR/AndroidRuntime(392): at android.os.Handler.dispatchMessage(Handler.java:99)
12-02 12:19:58.268: ERROR/AndroidRuntime(392): at android.os.Looper.loop(Looper.java:123)
12-02 12:19:58.268: ERROR/AndroidRuntime(392): at android.app.ActivityThread.main(ActivityThread.java:4363)
12-02 12:19:58.268: ERROR/AndroidRuntime(392): at java.lang.reflect.Method.invokeNative(Native Method)
12-02 12:19:58.268: ERROR/AndroidRuntime(392): at java.lang.reflect.Method.invoke(Method.java:521)
12-02 12:19:58.268: ERROR/AndroidRuntime(392): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
12-02 12:19:58.268: ERROR/AndroidRuntime(392): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
12-02 12:19:58.268: ERROR/AndroidRuntime(392): at 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 to signal 3
12-02 12:19:58.287: ERROR/dalvikvm(392): Unable to 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 any body please help me?
Thanks,
david,
progressDialog = new ProgressDialog((Context) myContext);
This is wrong, you can use instead of it:
And also, you forgot to call the
show()method to show the progressbar dialog box, write the below line at the end: