0

Here is my doubt:

I'm in fragment A and I need to open another fragment (B) to select some data and continue my execution. After select these data (In fragment B), how to close this fragment B and update and EditView text inside fragment A ?

After closing the fragment B, how to set an EditText text property inside fragment A? Even I set it on the "onCreateView" event, the text isn't updated.

If I try to set Button text (for instance), the text gets updated.

Hemerson Carlin
  • 7,354
  • 1
  • 27
  • 38
  • 1
    Store an string in your Activity. This way you will be able to update the value of the String in fragment B, and retrieve that value in fragment A. Other option would be to store the value of the String in SharedPreferences. – Luciano Rodríguez Nov 07 '14 at 16:32
  • @Luciano : just want to add this point to your correct comment : IMHO, storing in SharedPreferences should be used only to share data between activities and not fragments linked by the same activity – mithrop Nov 07 '14 at 16:34
  • 1
    @mithrop indeed i only use SharedPreferences to store user preferences, to pass data between activities i think passing Bundles as Extras through an Intent is the better choice. – Luciano Rodríguez Nov 07 '14 at 16:39
  • http://stackoverflow.com/questions/26129626/how-to-run-a-fragment-from-another-fragment/26130044#26130044 – Kristy Welsh Nov 07 '14 at 17:19
  • I tried @LucianoRodríguez way and it worked! However back on the "OnCreateView" (when I close the fragment B) event my EditText doesn´t update its text. If I try to update a Button text (same way as the EditText) the Button gets updated. – Hemerson Carlin Nov 07 '14 at 17:53
  • @mersocarlin How do you update your EditText text? – Luciano Rodríguez Nov 07 '14 at 19:57
  • I was setting the Text property of the EditText. I changed my Fragments to Activities and it works as I wanted to. Thanks for your help. – Hemerson Carlin Nov 10 '14 at 10:15

0 Answers0