android - How to Use onSaveInstanceState() -
I is the first person Muky_kriyashilta made three activities, said Na_btn the second, and the third called Samany_btn Muky_kriyashilta There are two other activities in which new buttons for button activity (new) and buttons for normal_button activity (normal) are included. New_button activity includes an EditText and a button called done_button Samany_btn activity within a TextView I used the effect to move the written data in EditText of new_button activity TextView in Samany_btn activity with the following code: < / P>
new_button (activity):
package com.tarek.topshine; Import android App Import android.content.Intent; Importroid.os.Bundle; Import android.view.Menu; Import android.view.View; Import android.widget.Button; Import android.widget.EditText; Public class expanded new_button activity (button done_button; String text; @ Override protected void was rescued from the Create (bundled Instensstet) {// Todo Auto-generated method stub super. Conet (saved Instensstet); setContentView (R. layout.new_button); AddListenerOnButton ();} public void addListenerOnButton () {done_button = (button) findViewById (R.id.done_button); Done_button.setOnClickListener (new View.OnClickListener () {public void onClick (View view) {edit Test editText = (EditText) findViewById (R.id.editText1); string At = EditTextkgetText (). ToString (); effect myIntent = new Intent (Dekenkget context (), Samany_btn. Class); MyIntentkputExtra ( "Maytekst", text); Prarnbwykti (Mereainntent);}}); }
General_button (activity):
package com.tarek.topshine; import android.app.importroid.os.bundle; import android.widget .TextView; Public category general_button activity (textview mTextview; @ override protected zero creation (InstanceState saved from bundle) {// Todo Auto-Genre Been method stub super. Connet (Saved Instantstate); SetContentView (R.layout.general_button); MTextview = (TextView) findViewById (R.id.textView1); MTextview.setText (.getIntent () getStringExtra ("mytext")); }}
Now the problem facing it is likely that I could not save consciously aware of the new_button activity Samany_btn activity, for example: I activity Samany_btn later Muky_kriyashilta Need to open and edit information. I have read on the internet that I can use the onSavedInstanceState method, but I could not understand it: (
Am I doing something wrong? And if I am, how do I solve it? !
Thanks for the help :)
You might be better, if you Usage
You can write an activity on it, write the same preference, which reads from the same priority.
Saving / restoring of the state is probably not of any help as you have shared the data here, not to recreate the same data.
Comments
Post a Comment