如何在不扩展 listactivity 类的情况下实现文件浏览器?我正在尝试在我的应用程序中添加一个选项来选择文件浏览器来选择他们自己的文件来使用而不是默认文件。我做了一个按钮,移动到文件浏览器列表,但是当我使用代码时setListAdapter(ArrayAdapter);
它说我需要扩展 ListActivity。当我这样做时,我在完全运行应用程序时遇到问题。关于我做错了什么的任何想法?我怎么能不用扩展listactivity,因为我的应用程序不仅仅是一个列表,它只需要使用列表。谢谢!
更新-LOGCAT
01-15 09:39:22.399: D/AndroidRuntime(317): Shutting down VM
01-15 09:39:22.409: W/dalvikvm(317): threadid=3: thread exiting with uncaught exception (group=0x4001b188)
01-15 09:39:22.409: E/AndroidRuntime(317): Uncaught handler: thread main exiting due to uncaught exception
01-15 09:39:22.429: E/AndroidRuntime(317): java.lang.IllegalStateException: Could not execute method of the activity
01-15 09:39:22.429: E/AndroidRuntime(317): at android.view.View$1.onClick(View.java:2031)
01-15 09:39:22.429: E/AndroidRuntime(317): at android.view.View.performClick(View.java:2364)
01-15 09:39:22.429: E/AndroidRuntime(317): at android.view.View.onTouchEvent(View.java:4179)
01-15 09:39:22.429: E/AndroidRuntime(317): at android.widget.TextView.onTouchEvent(TextView.java:6541)
01-15 09:39:22.429: E/AndroidRuntime(317): at android.view.View.dispatchTouchEvent(View.java:3709)
01-15 09:39:22.429: E/AndroidRuntime(317): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
01-15 09:39:22.429: E/AndroidRuntime(317): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
01-15 09:39:22.429: E/AndroidRuntime(317): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
01-15 09:39:22.429: E/AndroidRuntime(317): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
01-15 09:39:22.429: E/AndroidRuntime(317): at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:1659)
01-15 09:39:22.429: E/AndroidRuntime(317): at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1107)
01-15 09:39:22.429: E/AndroidRuntime(317): at android.app.Activity.dispatchTouchEvent(Activity.java:2061)
01-15 09:39:22.429: E/AndroidRuntime(317): at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1643)
01-15 09:39:22.429: E/AndroidRuntime(317): at android.view.ViewRoot.handleMessage(ViewRoot.java:1691)
01-15 09:39:22.429: E/AndroidRuntime(317): at android.os.Handler.dispatchMessage(Handler.java:99)
01-15 09:39:22.429: E/AndroidRuntime(317): at android.os.Looper.loop(Looper.java:123)
01-15 09:39:22.429: E/AndroidRuntime(317): at android.app.ActivityThread.main(ActivityThread.java:4363)
01-15 09:39:22.429: E/AndroidRuntime(317): at java.lang.reflect.Method.invokeNative(Native Method)
01-15 09:39:22.429: E/AndroidRuntime(317): at java.lang.reflect.Method.invoke(Method.java:521)
01-15 09:39:22.429: E/AndroidRuntime(317): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
01-15 09:39:22.429: E/AndroidRuntime(317): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
01-15 09:39:22.429: E/AndroidRuntime(317): at dalvik.system.NativeStart.main(Native Method)
01-15 09:39:22.429: E/AndroidRuntime(317): Caused by: java.lang.reflect.InvocationTargetException
01-15 09:39:22.429: E/AndroidRuntime(317): at phil.H.com.HIITActivity.changesong(HIITActivity.java:132)
01-15 09:39:22.429: E/AndroidRuntime(317): at java.lang.reflect.Method.invokeNative(Native Method)
01-15 09:39:22.429: E/AndroidRuntime(317): at java.lang.reflect.Method.invoke(Method.java:521)
01-15 09:39:22.429: E/AndroidRuntime(317): at android.view.View$1.onClick(View.java:2026)
01-15 09:39:22.429: E/AndroidRuntime(317): ... 21 more
01-15 09:39:22.429: E/AndroidRuntime(317): Caused by: java.lang.NullPointerException
01-15 09:39:22.429: E/AndroidRuntime(317): at phil.H.com.HIITActivity.getDir(HIITActivity.java:216)
01-15 09:39:22.429: E/AndroidRuntime(317): ... 25 more
01-15 09:39:22.509: I/Process(59): Sending signal. PID: 317 SIG: 3
01-15 09:39:22.509: I/dalvikvm(317): threadid=7: reacting to signal 3
01-15 09:39:22.609: I/dalvikvm(317): Wrote stack trace to '/data/anr/traces.txt'
01-15 09:44:22.559: I/Process(317): Sending signal. PID: 317 SIG: 9
01-15 09:44:22.659: E/JavaBinder(59): !!! FAILED BINDER TRANSACTION !!!
01-15 09:44:22.680: I/WindowManager(59): WIN DEATH: Window{44debcc8 phil.H.com/phil.H.com.HIITActivity paused=false}
01-15 09:44:22.680: I/ActivityManager(59): Process phil.H.com (pid 317) has died.
01-15 09:44:22.939: I/UsageStats(59): Unexpected resume of com.android.launcher while already resumed in phil.H.com
01-15 09:44:23.559: W/InputManagerService(59): Got RemoteException sending setActive(false) notification to pid 317 uid 10029