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);

 

Related Posts

Fix Plugin [id: ‘com.android.application’, version: ‘7.1.3’, apply: false] was not found in any of the following sources

Here is how to fix Plugin [id: ‘com.android.application’, version: ‘7.1.3’, apply: false] was not found in any of the following sources This error is caused by mismatching…

Get Age from Date of Birth in Java Android

Here is how to get a user’s age from date of birth If you need get a user’s age from a given date of birth string, this…

How to Check if String Array Contains a Specific String in Android

Here is how to get a specific value or String from Array in Android To check if a string array contains a specific string, you can use…

Make Android WebView Support Razorpay Payment

How to Support Razorpay Payment and UPI in Android WebView? Android webview is inexpensive and easy way to make apps for websites. But to support some specific…

Make Android Webview Support PayTM Google Pay PhonePe UPI

GooglePay, Phonpe and PayTM support in Android WebView If you have built an android app for your new ecommerce website or any other website that needs accept…

Leave a Reply

Your email address will not be published.