【问题标题】:How to add a textview to layout at runtime when a Toggle button is clicked in the same Layout [closed]当在同一布局中单击切换按钮时,如何在运行时将文本视图添加到布局[关闭]
【发布时间】:2012-11-22 08:38:25
【问题描述】:

当在同一布局中单击切换按钮时,如何在运行时将文本视图添加到布局???

【问题讨论】:

标签: android android-layout android-emulator


【解决方案1】:

这里有一个例子:

(点击按钮)

LinearLayout linearLayout = (LinearLayout) findViewById(R.id.mylayout)
TextView txt1 = new TextView(MyClass.this);
linearLayout.setBackgroundColor(Color.TRANSPARENT);
linearLayout.addView(txt1);

【讨论】:

  • 嘿,谢谢你的信息,当我点击切换到关闭状态时,我还需要 textview 消失
【解决方案2】:

显示/隐藏它可能会更容易。使用setVisibility(value),值可以是View.GONEView.INVISIBLEView.VISIBLE

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-10-19
    • 1970-01-01
    • 1970-01-01
    • 2013-04-10
    • 1970-01-01
    • 2019-02-20
    • 2014-10-28
    相关资源
    最近更新 更多