我想使用编辑文本设置输入值并从该模型中获取值,并且必须在TextView
中设置文本。我尝试了以下方法,但它无法正常工作:
主要活动
Mode setvalue = new Mode();
Mode getvalue = new Mode();
setvalue.set("jeeva",value1.getText().toString());
calculate.setText(getvalue.get("jeeva"));
模型类
public class Mode {
private HashMap<String, Object> data;
public Mode() {
this.data = new HashMap<String, Object>();
}
public Object get(String key) {
return this.data.get(key);
}
public void set(String key, Object value) {
this.data.put(key, value);
}
}
答案 0 :(得分:0)
试试这个
Mode mode = new Mode();
mode.set("jeeva", value1.getText().toString());
String value = (String) mode.get("jeeva");
calculate.setText(value);
希望有所帮助!