怎样使图像出现在指定的时间量,当按钮被点击?在日食 [英] How do I make an Image appear for a specified amount of time when a button is Clicked? In eclipse

查看:174
本文介绍了怎样使图像出现在指定的时间量,当按钮被点击?在日食的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

只是想知道我怎样才能使一个按钮,点击使图像视图看起来像半个秒然后消失,直到按钮再次点击。我使用的乔达时间

下面就是我的。我是新来的Java,如果你不能告诉已

 公共无效的onClick(视图v){
    // TODO自动生成方法存根
    DUR = 1;
    如果(barrelblast!= 0)
        sp.play(barrelblast,1,1,0,0,1);
            振动器盛传=(振动器)getSystemService(Context.VIBRATOR_SERVICE);
        vibe.vibrate(90);    如果(DUR!= 0)
       smoke.setVisibility(View.VISIBLE);
       Duration.standardSeconds(1);


解决方案

您可以试试这个:

 公共无效的onClick(视图v){smoke.setVisibility(View.VISIBLE);
处理器delayedAction =新的处理程序();delayedAction.postDelayed(新的Runnable(){公共无效的run(){smoke.setVisibility(View.INVISIBLE);                }       },500);}

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.

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

}

这篇关于怎样使图像出现在指定的时间量,当按钮被点击?在日食的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆