【发布时间】:2012-11-22 08:38:25
【问题描述】:
当在同一布局中单击切换按钮时,如何在运行时将文本视图添加到布局???
【问题讨论】:
-
您是否搜索过“动态添加文本视图”。如果是这样,您可能已经发现:stackoverflow.com/questions/4203506/…
标签: android android-layout android-emulator
当在同一布局中单击切换按钮时,如何在运行时将文本视图添加到布局???
【问题讨论】:
标签: android android-layout android-emulator
这里有一个例子:
(点击按钮)
LinearLayout linearLayout = (LinearLayout) findViewById(R.id.mylayout)
TextView txt1 = new TextView(MyClass.this);
linearLayout.setBackgroundColor(Color.TRANSPARENT);
linearLayout.addView(txt1);
【讨论】:
显示/隐藏它可能会更容易。使用setVisibility(value),值可以是View.GONE、View.INVISIBLE或View.VISIBLE。
【讨论】: