addressalign-toparrow-leftarrow-rightbackbellblockcalendarcameraccwcheckchevron-downchevron-leftchevron-rightchevron-small-downchevron-small-leftchevron-small-rightchevron-small-upchevron-upcircle-with-checkcircle-with-crosscircle-with-pluscrossdots-three-verticaleditemptyheartexporteye-with-lineeyefacebookfolderfullheartglobegmailgooglegroupshelp-with-circleimageimagesinstagramlinklocation-pinm-swarmSearchmailmessagesminusmoremuplabelShape 3 + Rectangle 1ShapeoutlookpersonJoin Group on CardStartprice-ribbonShapeShapeShapeShapeImported LayersImported LayersImported Layersshieldstartickettrashtriangle-downtriangle-uptwitteruserwarningyahoo

Re: [blrdroid] Get editText value and use to Button

From: Ankit
Sent on: Saturday, September 21, 2013 8:29 PM
Why you are using sharedPreference for this job? You can put strings in bundle and send it with intent when starting Activity1.

Ankit Goyal
[address removed]

On Sat, Sep 21, 2013 at 8:01 PM, kartheeswaran <[address removed]> wrote:
 I have four editText. I used sharedPreference for saving editText and get it later. I passed this editText value to another Activity button. I need to set first editText value to button. I used  

demomap.put(et.getText().toString(), et1.getText().toString());  demomap.put(et2.getText().toString(), et3.getText().toString());

But 2 buttons creating with et editText value and et2 editText value.




save.setOnClickListener(new OnClickListener(){

public void onClick(View v) {

 final Map<String, String> demomap = new HashMap<String, String>();
               demomap.put(et.getText().toString(), et1.getText().toString());
               demomap.put(et2.getText().toString(), et3.getText().toString());
               SharedPreferences preferences = getSharedPreferences("CREATE_MEAL",
               SharedPreferences.Editor editor = preferences.edit();
               for (Entry<String, String> entry : demomap.entrySet()) {
                   editor.putString(entry.getKey(), entry.getValue());

               Intent intent=new Intent(Activity.this,Activity1t.class);

Activity 1:

Here i set Button text from Activity SharedPrefereence.

demomap = new HashMap<String, String>();
        SharedPreferences preferences = getSharedPreferences("CREATE_MEAL", 0);
        for (Entry<String, ?> entry : preferences.getAll().entrySet()) {
            demomap.put(entry.getKey(), entry.getValue().toString());
        LinearLayout layout = (LinearLayout) findViewById(;
        Iterator myVeryOwnIterator = demomap.keySet().iterator();
        while (myVeryOwnIterator.hasNext()) {
            String key = (String);
            String value = (String) demomap.get(key);
            button = new Button(this);


Please Note: If you hit "REPLY", your message will be sent to everyone on this mailing list ([address removed])
This message was sent by kartheeswaran ([address removed]) from The Bangalore Android User Group - [ B.A.U.G ].
To learn more about kartheeswaran, visit his/her member profile
Set my mailing list to email me As they are sent | In one daily email | Don't send me mailing list messages

Meetup, POB 4668 #37895 NY NY USA 10163 | [address removed]

People in this
Meetup are also in:

Sign up

Meetup members, Log in

By clicking "Sign up" or "Sign up using Facebook", you confirm that you accept our Terms of Service & Privacy Policy