How can i implement a file browser, without exteniding the listactivity class? I’m trying to add an option in my app to choose a file browser to pick their own file to use instead of the default. I made a button, to move to the filebrowser list, but when i use the code setListAdapter(ArrayAdapter); It says i need to extend ListActivity. When i do this i have a problem running the app altogether. Any ideas of what i am doing wrong? How can i not have to extend the listactivity, because my app is not really only a list, it only needs to use the list. Thanks!
UPDATE-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
You don’t have to use
ListActivity. There just has to be aListViewobject within the layout you use, as long as you use the right methods on it.Set up a
ListViewin the XML file you inflate, then fetch it:Then, you can set its adapter:
The documentation has an awesome tutorial on a moderately advanced
ListViewimplementation.