我試圖在我的應用程序中實現ProgressBar,當我點擊播放聲音的Button時顯示。Android中的進度條
我已經完成了編碼,但是我得到了運行時異常並且應用程序沒有啓動。 在這裏,我發佈我的代碼供參考。
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);
}
});
的logcat的輸出是:
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
任何機構可以幫我嗎?
謝謝, 大衛,
如果您遇到異常,請發送logcat輸出。 – EboMike 2010-12-02 06:49:28