如何在哈希映射中使用数据模型设置文本视图 [英] How to set the text view using the data model in hash map
本文介绍了如何在哈希映射中使用数据模型设置文本视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想使用编辑文本设置输入值,并从该模型中获取值,并且必须在 TextView
中设置文本。我尝试了以下方法,但它不起作用:
主要活动
模式setvalue = new Mode();
Mode getvalue = new Mode();
$ b $ setvalue.set(jeeva,value1.getText()。toString());
calculate.setText(getvalue.get(jeeva));
模特班
public class Mode {
private HashMap< String,Object>数据;
$ b $ 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);
}
}
解决方案
<尝试像这样
Mode mode = new Mode();
mode.set(jeeva,value1.getText()。toString());
字符串值=(String)mode.get(jeeva);
calculate.setText(value);
希望它有帮助!
I want to set the input value using edit text and get the values from that model and have to set the text in TextView
. I have tried the following method, but it is not working:
Main Activity
Mode setvalue = new Mode();
Mode getvalue = new Mode();
setvalue.set("jeeva",value1.getText().toString());
calculate.setText(getvalue.get("jeeva"));
Model class
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);
}
}
解决方案
Try like this
Mode mode = new Mode();
mode.set("jeeva", value1.getText().toString());
String value = (String) mode.get("jeeva");
calculate.setText(value);
Hope its help!
这篇关于如何在哈希映射中使用数据模型设置文本视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文