android - how to resolve action bar not supporting for icon and text change setup? -
i unable debug problem.i.e.when trying change text name , put icon action bar not supporting..i mean throwing error
02-06 11:43:39.964 9510-9510/com.example.brahmaiah.app1_menu e/androidruntime: fatal exception: main process: com.example.brahmaiah.app1_menu, pid: 9510 java.lang.runtimeexception: unable start activity componentinfo{com.example.brahmaiah.app1_menu/com.example.brahmaiah.app1_menu.mainactivity}: java.lang.nullpointerexception: attempt invoke virtual method 'void android.support.v7.app.actionbar.seticon(int)' on null object reference @ android.app.activitythread.performlaunchactivity(activitythread.java:2325) @ android.app.activitythread.handlelaunchactivity(activitythread.java:2390) @ android.app.activitythread.access$800(activitythread.java:151) @ android.app.activitythread$h.handlemessage(activitythread.java:1303) @ android.os.handler.dispatchmessage(handler.java:102) @ android.os.looper.loop(looper.java:135) @ android.app.activitythread.main(activitythread.java:5257) @ java.lang.reflect.method.invoke(native method) @ java.lang.reflect.method.invoke(method.java:372) @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:903) @ com.android.internal.os.zygoteinit.main(zygoteinit.java:698) caused by: java.lang.nullpointerexception: attempt invoke virtual method 'void android.support.v7.app.actionbar.seticon(int)' on null object reference @ com.example.brahmaiah.app1_menu.mainactivity.oncreate(mainactivity.java:20) @ android.app.activity.performcreate(activity.java:5990) @ android.app.instrumentation.callactivityoncreate(instrumentation.java:1106) @ android.app.activitythread.performlaunchactivity(activitythread.java:2278) @ android.app.activitythread.handlelaunchactivity(activitythread.java:2390) @ android.app.activitythread.access$800(activitythread.java:151) @ android.app.activitythread$h.handlemessage(activitythread.java:1303) @ android.os.handler.dispatchmessage(handler.java:102) @ android.os.looper.loop(looper.java:135) @ android.app.activitythread.main(activitythread.java:5257) @ java.lang.reflect.method.invoke(native method) @ java.lang.reflect.method.invoke(method.java:372) @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:903) @ com.android.internal.os.zygoteinit.main(zygoteinit.java:698)
my mainactivity.java
@targetapi(build.version_codes.ice_cream_sandwich) @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.content_main); android.support.v7.app.actionbar actionbar=getsupportactionbar(); actionbar.seticon(r.drawable.ic_image3); toolbar toolbar = (toolbar) findviewbyid(r.id.my_toolbar); setsupportactionbar(toolbar);
and had support of v 7 , v 4 libraries.i tried execution in activityi.e.actionbar.getsupportactionbar();. kindly me in out of debug. think no need of manifest.xml..because had tag correctly minversion:7 , maxversion17..thanks in advance!! , app theme like...light.noactionbar
you need set toolbar
actionbar first use getsupportactionbar()
you need change below code
android.support.v7.app.actionbar actionbar=getsupportactionbar(); actionbar.seticon(r.drawable.ic_image3); toolbar toolbar = (toolbar) findviewbyid(r.id.my_toolbar); setsupportactionbar(toolbar);
to
toolbar toolbar = (toolbar) findviewbyid(r.id.my_toolbar); setsupportactionbar(toolbar); android.support.v7.app.actionbar actionbar=getsupportactionbar(); actionbar.seticon(r.drawable.ic_image3);
Comments
Post a Comment