04-05 14:58:47.224: I/System.out(264): /mnt/sdcard
04-05 14:59:21.451: D/dalvikvm(264): GC_FOR_MALLOC freed 5029 objects / 258800 bytes in 242ms
04-05 14:59:21.500: D/AndroidRuntime(264): Shutting down VM
04-05 14:59:21.500: W/dalvikvm(264): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
04-05 14:59:21.570: E/AndroidRuntime(264): FATAL EXCEPTION: main
04-05 14:59:21.570: E/AndroidRuntime(264): java.lang.IllegalStateException:
Could not find a method playMyRecord(View) in the activity class com.example.projectlayout.Showlist for onClick handler on view class android.widget.Button with id 'button1'
04-05 14:59:21.570: E/AndroidRuntime(264): at android.view.View$1.onClick(View.java:2059)
04-05 14:59:21.570: E/AndroidRuntime(264): at android.view.View.performClick(View.java:2408)
04-05 14:59:21.570: E/AndroidRuntime(264): at android.view.View$PerformClick.run(View.java:8816)
04-05 14:59:21.570: E/AndroidRuntime(264): at android.os.Handler.handleCallback(Handler.java:587)
04-05 14:59:21.570: E/AndroidRuntime(264): at android.os.Handler.dispatchMessage(Handler.java:92)
04-05 14:59:21.570: E/AndroidRuntime(264): at android.os.Looper.loop(Looper.java:123)
04-05 14:59:21.570: E/AndroidRuntime(264): at android.app.ActivityThread.main(ActivityThread.java:4627)
04-05 14:59:21.570: E/AndroidRuntime(264): at java.lang.reflect.Method.invokeNative(Native Method)
04-05 14:59:21.570: E/AndroidRuntime(264): at java.lang.reflect.Method.invoke(Method.java:521)
04-05 14:59:21.570: E/AndroidRuntime(264): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
04-05 14:59:21.570: E/AndroidRuntime(264): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
04-05 14:59:21.570: E/AndroidRuntime(264): at dalvik.system.NativeStart.main(Native Method)
04-05 14:59:21.570: E/AndroidRuntime(264): Caused by: java.lang.NoSuchMethodException: playMyRecord
04-05 14:59:21.570: E/AndroidRuntime(264): at java.lang.ClassCache.findMethodByName(ClassCache.java:308)
04-05 14:59:21.570: E/AndroidRuntime(264): at java.lang.Class.getMethod(Class.java:985)
04-05 14:59:21.570: E/AndroidRuntime(264): at android.view.View$1.onClick(View.java:2052)
04-05 14:59:21.570: E/AndroidRuntime(264): ... 11 more
04-05 14:59:25.211: I/Process(264): Sending signal. PID: 264 SIG: 9
04-05 15:01:05.641: I/System.out(322): /mnt/sdcard
04-05 15:01:33.525: D/dalvikvm(322): GC_FOR_MALLOC freed 5117 objects / 262576 bytes in 196ms
04-05 15:01:33.581: D/AndroidRuntime(322): Shutting down VM
04-05 15:01:33.581: W/dalvikvm(322): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
04-05 15:01:33.661: E/AndroidRuntime(322): FATAL EXCEPTION: main
04-05 15:01:33.661: E/AndroidRuntime(322): java.lang.IllegalStateException: Could not find a method playMyRecord(View) in the activity class com.example.projectlayout.Showlist for onClick handler on view class android.widget.Button with id 'button1'
04-05 15:01:33.661: E/AndroidRuntime(322): at android.view.View$1.onClick(View.java:2059)
04-05 15:01:33.661: E/AndroidRuntime(322): at android.view.View.performClick(View.java:2408)
04-05 15:01:33.661: E/AndroidRuntime(322): at android.view.View$PerformClick.run(View.java:8816)
04-05 15:01:33.661: E/AndroidRuntime(322): at android.os.Handler.handleCallback(Handler.java:587)
04-05 15:01:33.661: E/AndroidRuntime(322): at android.os.Handler.dispatchMessage(Handler.java:92)
04-05 15:01:33.661: E/AndroidRuntime(322): at android.os.Looper.loop(Looper.java:123)
04-05 15:01:33.661: E/AndroidRuntime(322): at android.app.ActivityThread.main(ActivityThread.java:4627)
04-05 15:01:33.661: E/AndroidRuntime(322): at java.lang.reflect.Method.invokeNative(Native Method)
04-05 15:01:33.661: E/AndroidRuntime(322): at java.lang.reflect.Method.invoke(Method.java:521)
04-05 15:01:33.661: E/AndroidRuntime(322): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
04-05 15:01:33.661: E/AndroidRuntime(322): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
04-05 15:01:33.661: E/AndroidRuntime(322): at dalvik.system.NativeStart.main(Native Method)
04-05 15:01:33.661: E/AndroidRuntime(322): Caused by: java.lang.NoSuchMethodException: playMyRecord
04-05 15:01:33.661: E/AndroidRuntime(322): at java.lang.ClassCache.findMethodByName(ClassCache.java:308)
04-05 15:01:33.661: E/AndroidRuntime(322): at java.lang.Class.getMethod(Class.java:985)
04-05 15:01:33.661: E/AndroidRuntime(322): at android.view.View$1.onClick(View.java:2052)
04-05 15:01:33.661: E/AndroidRuntime(322): ... 11 more
04-05 15:01:36.671: I/Process(322): Sending signal. PID: 322 SIG: 9
04-05 15:08:43.890: D/AndroidRuntime(394): Shutting down VM
04-05 15:08:43.890: W/dalvikvm(394): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
04-05 15:08:43.930: E/AndroidRuntime(394): FATAL EXCEPTION: main
04-05 15:08:43.930: E/AndroidRuntime(394): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.projectlayout/com.example.projectlayout.Showlist}: java.lang.ClassCastException: android.widget.Button
04-05 15:08:43.930: E/AndroidRuntime(394): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
04-05 15:08:43.930: E/AndroidRuntime(394): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
04-05 15:08:43.930: E/AndroidRuntime(394): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
04-05 15:08:43.930: E/AndroidRuntime(394): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
04-05 15:08:43.930: E/AndroidRuntime(394): at android.os.Handler.dispatchMessage(Handler.java:99)
04-05 15:08:43.930: E/AndroidRuntime(394): at android.os.Looper.loop(Looper.java:123)
04-05 15:08:43.930: E/AndroidRuntime(394): at android.app.ActivityThread.main(ActivityThread.java:4627)
04-05 15:08:43.930: E/AndroidRuntime(394): at java.lang.reflect.Method.invokeNative(Native Method)
04-05 15:08:43.930: E/AndroidRuntime(394): at java.lang.reflect.Method.invoke(Method.java:521)
04-05 15:08:43.930: E/AndroidRuntime(394): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
04-05 15:08:43.930: E/AndroidRuntime(394): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
04-05 15:08:43.930: E/AndroidRuntime(394): at dalvik.system.NativeStart.main(Native Method)
04-05 15:08:43.930: E/AndroidRuntime(394): Caused by: java.lang.ClassCastException: android.widget.Button
04-05 15:08:43.930: E/AndroidRuntime(394): at com.example.projectlayout.Showlist.onCreate(Showlist.java:41)
04-05 15:08:43.930: E/AndroidRuntime(394): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
04-05 15:08:43.930: E/AndroidRuntime(394): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
04-05 15:08:43.930: E/AndroidRuntime(394): ... 11 more
04-05 15:08:53.431: I/Process(394): Sending signal. PID: 394 SIG: 9
04-05 15:21:31.830: D/AndroidRuntime(418): Shutting down VM
04-05 15:21:31.830: W/dalvikvm(418): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
04-05 15:21:31.850: E/AndroidRuntime(418): FATAL EXCEPTION: main
04-05 15:21:31.850: E/AndroidRuntime(418): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.projectlayout/com.example.projectlayout.Showlist}: java.lang.ClassCastException: android.widget.Button
04-05 15:21:31.850: E/AndroidRuntime(418): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
04-05 15:21:31.850: E/AndroidRuntime(418): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
04-05 15:21:31.850: E/AndroidRuntime(418): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
04-05 15:21:31.850: E/AndroidRuntime(418): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
04-05 15:21:31.850: E/AndroidRuntime(418): at android.os.Handler.dispatchMessage(Handler.java:99)
04-05 15:21:31.850: E/AndroidRuntime(418): at android.os.Looper.loop(Looper.java:123)
04-05 15:21:31.850: E/AndroidRuntime(418): at android.app.ActivityThread.main(ActivityThread.java:4627)
04-05 15:21:31.850: E/AndroidRuntime(418): at java.lang.reflect.Method.invokeNative(Native Method)
04-05 15:21:31.850: E/AndroidRuntime(418): at java.lang.reflect.Method.invoke(Method.java:521)
04-05 15:21:31.850: E/AndroidRuntime(418): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
04-05 15:21:31.850: E/AndroidRuntime(418): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
04-05 15:21:31.850: E/AndroidRuntime(418): at dalvik.system.NativeStart.main(Native Method)
04-05 15:21:31.850: E/AndroidRuntime(418): Caused by: java.lang.ClassCastException: android.widget.Button
04-05 15:21:31.850: E/AndroidRuntime(418): at com.example.projectlayout.Showlist.onCreate(Showlist.java:41)
04-05 15:21:31.850: E/AndroidRuntime(418): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
04-05 15:21:31.850: E/AndroidRuntime(418): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
04-05 15:21:31.850: E/AndroidRuntime(418): ... 11 more
04-05 15:21:34.860: I/Process(418): Sending signal. PID: 418 SIG: 9
04-05 15:23:37.880: I/System.out(447): /mnt/sdcard
04-05 15:23:58.000: D/AndroidRuntime(447): Shutting down VM
04-05 15:23:58.000: W/dalvikvm(447): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
04-05 15:23:58.031: E/AndroidRuntime(447): FATAL EXCEPTION: main
04-05 15:23:58.031: E/AndroidRuntime(447): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.projectlayout/com.example.projectlayout.Showlist}: java.lang.ClassCastException: android.widget.Button
04-05 15:23:58.031: E/AndroidRuntime(447): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
04-05 15:23:58.031: E/AndroidRuntime(447): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
04-05 15:23:58.031: E/AndroidRuntime(447): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
04-05 15:23:58.031: E/AndroidRuntime(447): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
04-05 15:23:58.031: E/AndroidRuntime(447): at android.os.Handler.dispatchMessage(Handler.java:99)
04-05 15:23:58.031: E/AndroidRuntime(447): at android.os.Looper.loop(Looper.java:123)
04-05 15:23:58.031: E/AndroidRuntime(447): at android.app.ActivityThread.main(ActivityThread.java:4627)
04-05 15:23:58.031: E/AndroidRuntime(447): at java.lang.reflect.Method.invokeNative(Native Method)
04-05 15:23:58.031: E/AndroidRuntime(447): at java.lang.reflect.Method.invoke(Method.java:521)
04-05 15:23:58.031: E/AndroidRuntime(447): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
04-05 15:23:58.031: E/AndroidRuntime(447): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
04-05 15:23:58.031: E/AndroidRuntime(447): at dalvik.system.NativeStart.main(Native Method)
04-05 15:23:58.031: E/AndroidRuntime(447): Caused by: java.lang.ClassCastException: android.widget.Button
04-05 15:23:58.031: E/AndroidRuntime(447): at com.example.projectlayout.Showlist.onCreate(Showlist.java:41)
04-05 15:23:58.031: E/AndroidRuntime(447): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
04-05 15:23:58.031: E/AndroidRuntime(447): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
04-05 15:23:58.031: E/AndroidRuntime(447): ... 11 more
答案 0 :(得分:0)
要获取列表按钮的单击事件,您必须在适配器GetView方法中设置单击侦听器,如此
convertView.setOnClickListener(new OnItemClickListener(position));
private class OnItemClickListener implements OnClickListener {
private int mPosition;
OnItemClickListener(int position) {
mPosition = position;
}
@Override
public void onClick(View arg0) {
// do whatever you want to do
}
});
}
}
答案 1 :(得分:0)
Could not find a method playMyRecord(View) in the activity class com.example.projectlayout.Showlist for onClick handler on view class android.widget.Button with id 'button1'
从你的logcat 我可以看出你在xml中声明了onclick的方法,但是没有在java文件中定义该方法。 所以只需在java文件中声明你的方法playMyRecord(View)