How Can I Display Values From Edittext User Input?
Solution 1:
I think part of what you're looking for is to put your CustomStoreActivity code in onResume
instead of onCreate
. Whatever code you move into onResume
will occur whenever the CustomStoreActivity
is brought to the front (including when it is first created).
Another alternative, assuming that CustomStoreActivity
is used to launch the Activity
that contains the EditText
s, is to use startActivityForResult
and pass the data back in the result Intent
instead of using the SharedPreferences
. Here is a simple example (though note that the setResult
call in this example is passed null
where you would want to pass in an Intent
, as documented here in the Android docs).
It also seems like you're trying to use your second Activity
like a dialog box with editable fields. If that's the case, yet another alternative is to actually use a variant of the Dialog
class within your CustomStoreActivity
class instead of creating another Activity
to act like one. See the Android doc for dialogs.
Solution 2:
I'm not sure I really understand your question but are you trying to update the TextView of a different Activity from the one you are in? In which case I don't think this can be done and you should use Intents to pass the data to the activity
Post a Comment for "How Can I Display Values From Edittext User Input?"