简体   繁体   English

单击按钮后,如何在指定的时间内显示图像? 日食

[英]How do I make an Image appear for a specified amount of time when a button is Clicked? In eclipse

Just wondering how I can make a button click make an image view appear for like half a sec then disappear, until the button is clicked again. 只是想知道如何单击按钮才能使图像视图出现半秒钟,然后消失,直到再次单击该按钮。 I'm using joda-time 我正在使用乔达时间

Here's what I have. 这就是我所拥有的。 I'm new to java if you couldn't already tell. 如果您还不能告诉我,我是Java新手。

public void onClick(View v) {   
    // TODO Auto-generated method stub 
    dur = 1;
    if (barrelblast != 0)
        sp.play(barrelblast, 1, 1, 0, 0, 1);  
            Vibrator vibe = (Vibrator)getSystemService(Context.VIBRATOR_SERVICE);
        vibe.vibrate (90);  

    if (dur != 0)
       smoke.setVisibility(View.VISIBLE);
       Duration.standardSeconds(1); 

You can try this: 您可以尝试以下方法:

public void onClick(View v){

smoke.setVisibility(View.VISIBLE);
Handler delayedAction = new Handler();

delayedAction.postDelayed(new Runnable() {

public void run() {

smoke.setVisibility(View.INVISIBLE);

                }

       }, 500);

}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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