I'm working with fragments. Suppose I have fragmentA and fragmentB and I can go from fragmentA to fragmentB. In fragmentA I have a form (several edit texts). If I fill the form and then go to fragmentB and then press back button, all the information that I typed in the form is retained. From onCreateView I'm trying to do
String name = myEditText.getText().toString();
But I get empty result, even when I'm seeing the values in the form.
The question is, how can I access the content of this EditText in this situation?.
Solution
public void onResume() {
super.onResume();
String id = etIdHidden.getText().toString();
if(id.equals("")==false){
//Here do whatever you need, in my case I needed to change a bundle
mArgumentos=new Bundle();
mArgumentos.putString("id", ""+id);
}
};
Try fetching the value from the editText in the onResume() method. Also refer to the life-cycle of the fragment in the docs http://developer.android.com/guide/components/fragments.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With