将字符串转换为 TextView? [英] Converting string into TextView?
本文介绍了将字符串转换为 TextView?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
看看这段代码:
ArrayList<Object> row = data.get(position);
TextView idText = new TextView(this);
idText.setText(row.get(0).toString());
tableRow.addView(idText);
TextView storeText = new TextView(this);
idText.setText(row.get(1).toString());
tableRow.addView(storeText);
TextView maggiText = new TextView(this);
idText.setText(row.get(2).toString());
tableRow.addView(maggiText);
我必须手动创建一个 TextView
,将其设置为某个字符串,然后传递它.有没有一种方法可以将字符串直接传递给可以放入 for
循环中的行?
I have to manually create a TextView
, set it to some string and then pass it. Is there a way by which I can directly pass the string to row that can be put in a for
loop?
我正在寻找这种方法来解决可扩展性问题.
I am looking for this approach for scalability issues.
推荐答案
///复制粘贴时出错
//所有电视中使用的idText
//idText using in all Tv
按照下面的方式进行
TextView idText = new TextView(this);
idText.setText(row.get(0).toString());
tableRow.addView(idText);
TextView storeText = new TextView(this);
storeText.setText(row.get(1).toString());
tableRow.addView(storeText);
TextView maggiText = new TextView(this);
maggiText.setText(row.get(2).toString());
tableRow.addView(maggiText);
这篇关于将字符串转换为 TextView?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文