Android: Use edittext input to set text of a button?
I save my edditext text:
final EditText Zipcodeinput 开发者_高级运维= (EditText) findViewById(R.id.Zipcode);
SharedPreferences settings = getSharedPreferences("cars4sale",0);
SharedPreferences.Editor editor = settings.edit();
editor.putString("zip", Zipcodeinput.getText().toString());
editor.commit();
I want to use the string "zip" to set the android:text=" " for one of my Buttons. I'm don't know how to go about this I've read about layoutinflator but it seems overly complex for what I'm trying to do.
Thanks for the help in advance, -Nick
First you would find the Button in question
Button button1 = (Button)findViewById(R.id.button1);
and then use the setText method to change its text
SharedPreferences settings = getSharedPreferences("cars4sale",0);
String zipStr = settings.getString("zip", "");
button1.setText(zipStr);
精彩评论