[英]how to show a toast message and make a button invisible after click?
How can i after a button is clicked, first, to show a toast message, and then after 1 second to make the button invisible?单击按钮后,我如何首先显示敬酒消息,然后在 1 秒后使按钮不可见?
Boolean isVisible = true;
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (isVisible){
Toast.makeText(MainActivity.this, "This is a toast", Toast.LENGTH_SHORT).show();
new Handler(Looper.getMainLooper()).postDelayed(new Runnable() {
@Override
public void run() {
button.setVisibility(View.INVISIBLE);
}
},1000);
} else {
button.setVisibility(View.VISIBLE);
}
}
});
I hope this is what u r looking for我希望这就是你要找的 r
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.