on pressing settings, plain whit screen, layout not drawn over, set breakpoints check happening. class gets called, oncreate()
doesn't called.
here's code -
public class settingsactivity extends appcompatactivity { @injectview(r.id.settings_toolbar) toolbar toolbar; @override public void oncreate(bundle savedinstancestate, persistablebundle persistentstate) { super.oncreate(savedinstancestate, persistentstate); setcontentview(r.layout.settings_toolbar); butterknife.inject(this); setsupportactionbar(toolbar); getfragmentmanager().begintransaction(). replace(r.id.content_frame, new mypreferencefragment()).commit(); } public static class mypreferencefragment extends preferencefragment { @override public void oncreate(final bundle savedinstancestate){ super.oncreate(savedinstancestate); addpreferencesfromresource(r.xml.preferences); } } }
and here's layout file -
<?xml version="1.0" encoding="utf-8"?> <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent"> <android.support.v7.widget.toolbar xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:elevation="20dp" android:id="@+id/settings_toolbar" android:theme="@style/apptheme.base" android:layout_height="wrap_content" android:background="?attr/colorprimary" android:minheight="?attr/actionbarsize" /> <framelayout android:id="@+id/content_frame" android:layout_below="@+id/settings_toolbar" android:layout_width="match_parent" android:layout_height="match_parent" /> </relativelayout>
try use
protected void oncreate(bundle savedinstancestate)
instead of
public void oncreate(bundle savedinstancestate, persistablebundle persistentstate)
Comments
Post a Comment