android - Clicking toolbar navigation icon crashes the app -
trying new toolbar widget in android 5.0. set toolbar's navigation icon , tried use it. when tap on button on toolbar following error:
fatal exception: main java.lang.illegalargumentexception: invalid payload item type @ android.util.eventlog.writeevent(native method) @ android.app.activity.onmenuitemselected(activity.java:2628) @ android.support.v4.app.fragmentactivity.onmenuitemselected(fragmentactivity.java:350) @ android.support.v7.app.actionbaractivity.onmenuitemselected(actionbaractivity.java:155) @ android.support.v7.app.actionbaractivitydelegate$1.onmenuitemselected(actionbaractivitydelegate.java:74) @ android.support.v7.widget.windowcallbackwrapper.onmenuitemselected(windowcallbackwrapper.java:44) @ android.support.v7.internal.widget.toolbarwidgetwrapper$1.onclick(toolbarwidgetwrapper.java:190) @ android.view.view.performclick(view.java:4211) @ android.view.view$performclick.run(view.java:17267) @ android.os.handler.handlecallback(handler.java:615) @ android.os.handler.dispatchmessage(handler.java:92) @ android.os.looper.loop(looper.java:137) @ android.app.activitythread.main(activitythread.java:4898) @ java.lang.reflect.method.invokenative(native method) @ java.lang.reflect.method.invoke(method.java:511) @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:1006) @ com.android.internal.os.zygoteinit.main(zygoteinit.java:773) @ dalvik.system.nativestart.main(native method)
moreover, if use phone button no error. quits settings activity.
settings activity:
public class activitysettings extends actionbaractivity { private toolbar toolbar; private drawerlayout drawerlayout; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_settings); inittoolbar(); // display fragment main content. getfragmentmanager().begintransaction() .replace(r.id.container, new fragmentsettings()).commit(); } private void inittoolbar() { toolbar = (toolbar) findviewbyid(r.id.toolbar); if (toolbar != null) { // toolbar.setnavigationicon(r.drawable.ic_drawer); toolbar.settitle(html.fromhtml("<font color=\"white\">" + getstring(r.string.settings_header_title) + "</font>")); setsupportactionbar(toolbar); getsupportactionbar().setdisplayhomeasupenabled(true); } } }
and androidmanifest:
<activity android:name=".activitysettings" android:label="@string/settings_header_title" android:parentactivityname=".activitymain" > <meta-data android:name="android.support.parent_activity" android:value=".activitymain" /> </activity>
i tried cleaning solution, removing mafifest parent activity name , setting click listener toolbar
toolbar.setnavigationonclicklistener(new onclicklistener() { @override public void onclick(view v) { finish(); } });
but gave same error.
in advance!
device: samsung galaxy s3
android: 4.1.2
screenshot
the problem in the
toolbar.settitle(html.fromhtml("<font color=\"white\">sample text</font>"));
somehow, android not allow setting title html strings. (it allows when click button crashes) tried add cdata it didn't work.
html.fromhtml("<![cdata[<font color=\"white\">sample text</font>]]>");
as had set title in androidmanifest.xml
android:label="@string/settings_header_title"
i had remove line setting title.
Comments
Post a Comment