简体   繁体   中英

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.

You can set particular View's visibility Like :

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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