林具有TextView的设置为不可见/可见一些麻烦。
Im having some trouble with setting textview to invisible/visible.
basicly我希望这样一个开/关按钮被点击的时候。
basicly i want this to happen when an on/off button has been clicked.
我所做的是一种像
textview.setVisibility(TextView.VISIBLE);
textview.setVisibility(TextView.INVISIBLE);
当我尝试执行此emultor说,应用程序已经停止unexcpetedly
when i try executing this the emultor says that the app has stopped unexcpetedly
您从XML构建这样或编程?
Are you building this from XML or programmatically?
我想使它成为一个XML文件,然后在活动运行更改属性。一定要使用的setContentView(R.layout.main);
,然后再尝试获得与 findViewById(...)TextView的
。
I would make it with an XML file then when the Activity runs change the property. Be sure to use setContentView(R.layout.main);
before you try to get the TextView with findViewById(...)
.
呼叫 .setVisibility(View.GONE);
上的TextView将其隐藏
Call .setVisibility(View.GONE);
on the TextView to hide it.
呼叫 .setVisibility(View.VISIBLE);
来的TextView的表现出来。
Call .setVisibility(View.VISIBLE);
to on the TextView to show it.
我有做这样的事情的一个例子。你可以看到code在这里:https://github.com/ethankhall/Morse-Messenger/blob/master/src/com/kopysoft/MorseMessenger/Translate.java
I have an example that does something like this. You can see the code here: https://github.com/ethankhall/Morse-Messenger/blob/master/src/com/kopysoft/MorseMessenger/Translate.java