Here is How to Hide or Show a View After Some Seconds in Android Java

How to show, hide, or do an action in android after some seconds – Android Studio Tutorial

Sometimes, we need hide or show a view, open an activity or execute a method  after a certain amounts of seconds or minutes in android development. For this, we can use a timer method. The code below can do it. Using the code, you can do most types of operations after a set time.

The timing is calculated in milli seconds, so a time such as 3000 is 3 seconds, 5000 is 5 seconds

Here is the code of Android Timer Function

new Handler().postDelayed(new Runnable() {
@Override
public void run() {
// do your operation here
}
}, 3000);

 

To hide a view afer your x seconds, you can do like this.

YourView.setVisibility(view.Gone);

 

Post navigation

Comments

This site uses Akismet to reduce spam. Learn how your comment data is processed.