Android开发反复TextView的知名度 [英] Android development toggling TextView visibility

查看:96
本文介绍了Android开发反复TextView的知名度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

林具有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在这里:<一href="https://github.com/ethankhall/Morse-Messenger/blob/master/src/com/kopysoft/MorseMessenger/Translate.java">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

这篇关于Android开发反复TextView的知名度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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