Android:以编程方式创建TextView [英] Android: Creating a TextView programmatically
本文介绍了Android:以编程方式创建TextView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何使用layout_width=fill_parent
创建TextView
(使用Java代码而不是xml)?
How can I create a TextView
(with Java code, not xml) with layout_width=fill_parent
?
TextView
应该是可编辑的.
推荐答案
如果我不正确地理解问题,则需要以编程方式创建EditText
.然后,尝试使用:
If i don't understand question wrongly,you need to create an EditText
programatically.then,Try using:
EditText et=new EditText(context);
et.setLayoutParams(new Gallery.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
导入LayoutParams:
Import for LayoutParams:
import android.view.ViewGroup.LayoutParams;
这篇关于Android:以编程方式创建TextView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文