setcontentview - Application Forces to close when I start another activity through Intent and display a text -
app force closes when try start intent , display text have included setcontentview(r.layout.activity_try_text);
public class trytext extends actionbaractivity { @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_try_text); textview text = (textview)findviewbyid(r.id.textview11); text.settext("hi"); } }
and here logcat
06-30 12:03:05.115: i/process(698): sending signal. pid: 698 sig: 9 06-30 12:03:11.802: d/androidruntime(1327): shutting down vm 06-30 12:03:11.802: w/dalvikvm(1327): threadid=1: thread exiting uncaught exception (group=0x41b7bd40) 06-30 12:03:11.807: e/androidruntime(1327): fatal exception: main 06-30 12:03:11.807: e/androidruntime(1327): process: com.example.bag, pid: 1327 06-30 12:03:11.807: e/androidruntime(1327): java.lang.runtimeexception: unable start activity componentinfo{com.example.bag/com.example.bag.trytext}: java.lang.nullpointerexception 06-30 12:03:11.807: e/androidruntime(1327): @ android.app.activitythread.performlaunchactivity(activitythread.java:2209) 06-30 12:03:11.807: e/androidruntime(1327): @ android.app.activitythread.handlelaunchactivity(activitythread.java:2269) 06-30 12:03:11.807: e/androidruntime(1327): @ android.app.activitythread.access$800(activitythread.java:139) 06-30 12:03:11.807: e/androidruntime(1327): @ android.app.activitythread$h.handlemessage(activitythread.java:1210) 06-30 12:03:11.807: e/androidruntime(1327): @ android.os.handler.dispatchmessage(handler.java:102) 06-30 12:03:11.807: e/androidruntime(1327): @ android.os.looper.loop(looper.java:136) 06-30 12:03:11.807: e/androidruntime(1327): @ android.app.activitythread.main(activitythread.java:5102) 06-30 12:03:11.807: e/androidruntime(1327): @ java.lang.reflect.method.invokenative(native method) 06-30 12:03:11.807: e/androidruntime(1327): @ java.lang.reflect.method.invoke(method.java:515) 06-30 12:03:11.807: e/androidruntime(1327): @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:785) 06-30 12:03:11.807: e/androidruntime(1327): @ com.android.internal.os.zygoteinit.main(zygoteinit.java:601) 06-30 12:03:11.807: e/androidruntime(1327): @ dalvik.system.nativestart.main(native method) 06-30 12:03:11.807: e/androidruntime(1327): caused by: java.lang.nullpointerexception 06-30 12:03:11.807: e/androidruntime(1327): @ android.view.viewgroup.addviewinner(viewgroup.java:3561) 06-30 12:03:11.807: e/androidruntime(1327): @ android.view.viewgroup.addview(viewgroup.java:3415) 06-30 12:03:11.807: e/androidruntime(1327): @ android.view.viewgroup.addview(viewgroup.java:3391) 06-30 12:03:11.807: e/androidruntime(1327): @ com.android.internal.policy.impl.phonewindow.setcontentview(phonewindow.java:309) 06-30 12:03:11.807: e/androidruntime(1327): @ com.android.internal.policy.impl.phonewindow.setcontentview(phonewindow.java:299) 06-30 12:03:11.807: e/androidruntime(1327): @ android.app.activity.setcontentview(activity.java:1957) 06-30 12:03:11.807: e/androidruntime(1327): @ android.support.v7.app.actionbaractivity.supersetcontentview(actionbaractivity.java:220) 06-30 12:03:11.807: e/androidruntime(1327): @ android.support.v7.app.actionbaractivitydelegateics.setcontentview(actionbaractivitydelegateics.java:106) 06-30 12:03:11.807: e/androidruntime(1327): @ android.support.v7.app.actionbaractivity.setcontentview(actionbaractivity.java:81) 06-30 12:03:11.807: e/androidruntime(1327): @ com.example.bag.trytext.oncreate(trytext.java:21) 06-30 12:03:11.807: e/androidruntime(1327): @ android.app.activity.performcreate(activity.java:5248) 06-30 12:03:11.807: e/androidruntime(1327): @ android.app.instrumentation.callactivityoncreate(instrumentation.java:1110) 06-30 12:03:11.807: e/androidruntime(1327): @ android.app.activitythread.performlaunchactivity(activitythread.java:2173) 06-30 12:03:11.807: e/androidruntime(1327): ... 11 more
try removing line:
setcontentview(text);
as have inflated view.
if doesn't work, post logcat.
hope helps
Comments
Post a Comment