Translate this page

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

Get Your Own Android Mobile App for Your Website Today

Are you looking to expand your online presence and reach more customers? In today’s digital age, having a mobile app is an essential tool to connect with…

Why making an app for your website can help your business to grow

In today’s digital age, it’s more important than ever to have a strong online presence. Whether you’re running a business, a blog, or a personal website, having…

person using macbook pro on person s lap

Fix android.content.Intent.migrateExtraStreamToClipData(android.content.Context)’ on a null object reference

Here is how to Fix Android Studio Error Attempt to invoke virtual method ‘boolean android.content.Intent.migrateExtraStreamToClipData(android.content.Context)’ on a null object reference This error is caused by a number…

Android Spinner onItemSelected Listener Example

Spinner is an android UI element; it provides a drop-down List where you can choose an item from the list. You will need a listener to catch…

person in gray shirt holding a small paper with texts

Get Current Month Name in Java Android

The code below can be used to get the name of current month, for example, January, February, March etc. Just call this method and it will return…

The future of android developers is not good

Are you an android developer or looking to be an android developer? You should read this Myself is zid, I’m an android developer and been in this…

Leave a Reply

Your email address will not be published. Required fields are marked *