android - Toolbar title changes on rotation on device to entered text in an EditText? -


i have edittext directly under toolbar. when device rotates, toolbar's title, (set xml) changes edittext's current text.

    <android.support.v7.widget.toolbar     android:id="@+id/toolbar"     android:layout_width="match_parent"     android:layout_height="?attr/actionbarsize"     android:background="@color/colorprimary"     android:theme="@style/themeoverlay.appcompat.actionbar"     app:popuptheme="@style/themeoverlay.appcompat.light">      <textview         android:id="@+id/title"         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:layout_gravity="center"         android:text="@string/newoccasion"         android:textcolor="#ffffff"         android:textsize="18sp" /> </android.support.v7.widget.toolbar>  <edittext     android:id="@+id/titleet"     android:layout_width="match_parent"     android:layout_height="wrap_content"     android:layout_marginbottom="20dp"     android:drawablestart="@drawable/ic_title"     android:hint="@string/titleet"     android:maxlines="1"     android:nextfocusleft="@+id/titleet"     android:nextfocusup="@+id/titleet"     android:paddingend="5dp"     android:paddingstart="5dp"     android:textsize="17sp"     android:theme="@style/inputcolors"     android:lines="1"     android:maxlength="35"/> 

full xml here: http://pastebin.com/jbeakvqy

after 3 hours of tiredness, found it.

just override these methods in activity:

@override public void onsaveinstancestate(bundle savedinstancestate) {     // call superclass can save view hierarchy state     super.onsaveinstancestate(savedinstancestate); } @override protected void onrestoreinstancestate(bundle savedinstancestate) {     //do nothing } 

it worked perfectly. these restore previous texts way when such rotating device.


Comments