如何从android中动态创建的TextView获取文本? [英] How to get text from dynamically created TextView in android?
本文介绍了如何从android中动态创建的TextView获取文本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
private void textview(String question) {
TextView clientAddress = new TextView(this);
clientName.setGravity(1);
clientAddress.setTypeface(Typeface.defaultFromStyle(1));
clientAddress.setText(question);
clientAddress.setLayoutParams(lparams);
linearLayout.addView(clientAddress);
clientAddress.setTextSize(20);
clientAddress.setTextColor(getResources().getColor(R.color.white));
clientAddress.setPadding(7, 10, 0, 10);
}
我正在调用此函数来动态创建 6 个 TextView.但我很困惑,如何从这些 TextViews 中获取文本.谁能建议我解决方案?
I am calling this function to create 6 TextViews dynamically. but i am confused , how to get text from these TextViews. can anyone suggest me the solution?
推荐答案
您可以使用 gettext() 方法从文本视图中获取文本.如果要将获取的文本转换为字符串,则可以使用 tostring() .
you can use the gettext() method to get the text from the text view. and if you wants to convert the fetched text into string then you can use tostring() .
String fetchedtext = clientAddress.getText().toString();
这篇关于如何从android中动态创建的TextView获取文本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文