我保存我的edditext文本:

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();


我想使用字符串“ zip”为我的一个按钮设置android:text =“”。我不知道该怎么做,因为我已经阅读了有关layoutinflator的内容,但是对于我想做的事情来说似乎过于复杂。

我在这里先向您的帮助表示感谢,
-缺口

最佳答案

首先,您会发现有问题的按钮

Button button1 = (Button)findViewById(R.id.button1);


然后使用setText方法更改其文本

SharedPreferences settings = getSharedPreferences("cars4sale",0);
String zipStr = settings.getString("zip", "");
button1.setText(zipStr);

10-07 19:21
查看更多