安卓:绘制文字编辑(S)或TextView的(S),当用户输入他们的号码[EXP:6再画​​6 TextView的。 [英] Android : Draw TextEdit(s) or TextView(s) when user enter number of them.[exp: 6 then draw 6 TextView]

查看:213
本文介绍了安卓:绘制文字编辑(S)或TextView的(S),当用户输入他们的号码[EXP:6再画​​6 TextView的。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Wantto要求用户输入TextEdit或ViewText的号码,然后绘制它们。
对于-例如用户输入7,然后7 ViewText draw.I知道这是一个合适的方式,但在我prgrm的我不能改变整个结构,我在得到这个埃罗:

Wantto ask user to enter number of TextEdit or ViewText and then draw them. For-example user enter 7,then seven ViewText draw.I knew this is a suitable way but in my prgrm i cant change the whole structure,the i got this erro at:

    tv = new TextView(this);

和错误是:构造的TextView(新View.OnClickListener(){})是不确定的

and error is: "The constructor TextView(new View.OnClickListener(){}) is undefined".

我知道我必须做的:

    implements OnClickListener

但我不能改变PRGRM now.SO反正是有没有refrence它'布局'XML创建的TextView(或任何查看objct)?

but i cant change the prgrm now.SO is there anyway to create TextView(or any View objct) without refrence it to 'layout' xml?

    LinearLayout ll = (LinearLayout)findViewById(R.id.myLL);
    for(int i=1 ; i<= 10 ; i++){
      TextView tv = new TextView(this);
      tv.setText("String/String/String");
      ll.addView(tv);
      } 

感谢,,

推荐答案

您要添加的LinearLayout本身。最后一行应 ll.addView(TV);

You're adding the LinearLayout to itself. The last line should be ll.addView(tv);

这篇关于安卓:绘制文字编辑(S)或TextView的(S),当用户输入他们的号码[EXP:6再画​​6 TextView的。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆