Android 我想做一个带定时器的按钮?
我想在安卓系统中制作一个带定时器的按钮,如果用户点击这个按钮,那么按钮在30分钟前就不能工作了。时间将显示在该按钮的右侧。 有人能帮我吗?Android 我想做一个带定时器的按钮?,android,android-studio,android-layout,button,Android,Android Studio,Android Layout,Button,我想在安卓系统中制作一个带定时器的按钮,如果用户点击这个按钮,那么按钮在30分钟前就不能工作了。时间将显示在该按钮的右侧。 有人能帮我吗? 谢谢请尝试以下代码: int minutes = 30; int seconds = 60; //here in id place your button id Button button = (Button)findViewById(R.id.button_id) button.setOnClickListener(new OnClickListene
谢谢请尝试以下代码:
int minutes = 30;
int seconds = 60;
//here in id place your button id
Button button = (Button)findViewById(R.id.button_id)
button.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
((Button) findViewById(R.id.click)).setEnabled(false);
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
\\ your button action here
}
},minutes*seconds*1000);
}
});
你能发布你到目前为止尝试过的吗?我向你展示了如何延迟使用按钮,但是你应该在run函数中编写代码,通过创建一个新的timmer来更改按钮上的文本,并尝试使用此链接中的代码[