SamRowley
SamRowley

Reputation: 3485

Make ImageView visible for set amount of time

I have an onClick method set in the xml layout file that triggers the vibration of the phone for 100ms at this point I have the ImageView Visibility set to visible so it can be seen. I want the ImageView to be set back to gone again when the vibration has stopped. How do I go about this?

Upvotes: 2

Views: 4824

Answers (1)

Lumis
Lumis

Reputation: 21639

You can start this method at the same time:

public void timerDelayRemoveView(float time, final ImageView v) {
    Handler handler = new Handler(); 
    handler.postDelayed(new Runnable() {           
        public void run() {                
            v.setVisibility(View.GONE);      
        }
    }, time); 
}

Upvotes: 11

Related Questions