0

I have got a runtime exception while developing an App. Here is my LogCat.

11-06 12:56:09.977: INFO/ActivityManager(59): Starting activity: Intent { cmp=balu.android/.CommonNames }
11-06 12:56:10.096: INFO/CommonNameTable(516): OPening DataBase Connection....
11-06 12:56:10.156: INFO/global(516): Default buffer size used in BufferedReader constructor. It would be better to be explicit if an 8k-char buffer is required.
11-06 12:56:10.156: INFO/CommonNameTable(516): Inserting record...
11-06 12:56:10.306: INFO/CommonNameTable(516): Inserting record...
11-06 12:56:10.428: INFO/CommonNameTable(516): Inserting record...
11-06 12:56:10.546: INFO/CommonNameTable(516): OPening DataBase Connection....
11-06 12:56:10.576: DEBUG/AndroidRuntime(516): Shutting down VM
11-06 12:56:10.576: WARN/dalvikvm(516): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
11-06 12:56:10.596: ERROR/AndroidRuntime(516): FATAL EXCEPTION: main
11-06 12:56:10.596: ERROR/AndroidRuntime(516): java.lang.RuntimeException: Unable to start activity ComponentInfo{balu.android/balu.android.CommonNames}: java.lang.ClassCastException: android.widget.TextView
11-06 12:56:10.596: ERROR/AndroidRuntime(516):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
11-06 12:56:10.596: ERROR/AndroidRuntime(516):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
11-06 12:56:10.596: ERROR/AndroidRuntime(516):     at android.app.ActivityThread.access$2300(ActivityThread.java:125)
11-06 12:56:10.596: ERROR/AndroidRuntime(516):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
11-06 12:56:10.596: ERROR/AndroidRuntime(516):     at android.os.Handler.dispatchMessage(Handler.java:99)
11-06 12:56:10.596: ERROR/AndroidRuntime(516):     at android.os.Looper.loop(Looper.java:123)
11-06 12:56:10.596: ERROR/AndroidRuntime(516):     at android.app.ActivityThread.main(ActivityThread.java:4627)
11-06 12:56:10.596: ERROR/AndroidRuntime(516):     at java.lang.reflect.Method.invokeNative(Native Method)
11-06 12:56:10.596: ERROR/AndroidRuntime(516):     at java.lang.reflect.Method.invoke(Method.java:521)
11-06 12:56:10.596: ERROR/AndroidRuntime(516):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
11-06 12:56:10.596: ERROR/AndroidRuntime(516):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
11-06 12:56:10.596: ERROR/AndroidRuntime(516):     at dalvik.system.NativeStart.main(Native Method)
11-06 12:56:10.596: ERROR/AndroidRuntime(516): Caused by: java.lang.ClassCastException: android.widget.TextView
11-06 12:56:10.596: ERROR/AndroidRuntime(516):     at balu.android.CommonNames.onCreate(CommonNames.java:31)
11-06 12:56:10.596: ERROR/AndroidRuntime(516):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
11-06 12:56:10.596: ERROR/AndroidRuntime(516):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
11-06 12:56:10.596: ERROR/AndroidRuntime(516):     ... 11 more
11-06 12:56:10.616: WARN/ActivityManager(59):   Force finishing activity balu.android/.CommonNames
11-06 12:56:10.626: WARN/ActivityManager(59):   Force finishing activity balu.android/.Select
11-06 12:56:11.183: WARN/ActivityManager(59): Activity pause timeout for HistoryRecord{450af6e8 balu.android/.CommonNames}
11-06 12:56:20.036: WARN/ActivityManager(59): Launch timeout has expired, giving up wake lock!
11-06 12:56:20.125: WARN/ActivityManager(59): Activity idle timeout for HistoryRecord{450af6e8 balu.android/.CommonNames}
11-06 12:56:21.252: WARN/ActivityManager(59): Activity idle timeout for HistoryRecord{44fd7b98 balu.android/.BabyNamesAppActivity}
11-06 12:56:26.456: DEBUG/dalvikvm(132): GC_EXPLICIT freed 1211 objects / 86976 bytes in 177ms

I think this is the source of the problem.

https://github.com/Balu-Varanasi/BabyNamesApp/blob/master/src/balu/android/CommonNameTable.java https://github.com/Balu-Varanasi/BabyNamesApp/blob/master/src/balu/android/CommonNames.java

Could you please help me in fixing this problem?

1
  • put your code where you are getting this exception > Commented Nov 6, 2011 at 8:06

1 Answer 1

2

I've got it:

In CommonNames.java you 're using this code:

 ListView cnListView = (ListView)findViewById(R.id.commonName);

But R.id.commonName is TextView.

Your layout.listview just represents only listview's item structure.

You need to create new xml which will describe the Activity's layout with its ListView component. And then after

super.onCreate(..);

do

setContentView(R.layout.your_activity_layout_with_list)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.