简体   繁体   English

如何使文本视图出现和消失?

[英]How to make a textview appear and disappear?

The default is disappear.默认是消失。 I want to know how to make a text-view appear and disappear.我想知道如何使text-view出现和消失。

You can set particular View's visibility Like :您可以设置特定View's可见性,例如:

yourTextViewName.setVisibility(View.VISIBLE) // For Visible/Appear

yourTextViewName.setVisibility(View.INVISIBLE)  // For Invisible/Disappear

yourTextViewName.setVisibility(View.GONE)   // For Gone / View not takes any space at Run time

Hope this will Helps.(:希望这会有所帮助。(:

Here is the method you are looking for;这是您正在寻找的方法;

private void makeTextViewDisappear(){
    yourTV.setVisibility(View.VISIBLE);
    new Handler().postDelayed(new Runnable() {
        @Override
        public void run() {
            yourTV.setVisibility(View.INVISIBLE);
            // OR yourTV.setVisibility(View.GONE) to reclaim the space used by textview
        }
    }, 10000); //for 10 seconds
}

If this worked, don't forget to mark this as the right answer.如果这有效,请不要忘记将其标记为正确答案。 Regards.问候。

new Handler().postDelayed(new Runnable() {
                @Override
                public void run() {
                   yourTextViewName.setVisibility(View.VISIBLE)
                }
            }, 5000); <--- change time here

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM