Java 如何在单击按钮后执行操作
我需要在OnClickListener的onClick方法运行之后执行一个操作 以下是我的onClickListener代码: 在这已经运行,背景设置好之后,我想调用一个checkerlint方法标识符,它将检查其他打开的平铺并相应地更改背景 此方法需要单独运行,因为只有在onClick完成后才会显示背景,并且我需要在checker方法将其更改为其他内容之前显示一段短时间的预定背景Java 如何在单击按钮后执行操作,java,android,onclicklistener,Java,Android,Onclicklistener,我需要在OnClickListener的onClick方法运行之后执行一个操作 以下是我的onClickListener代码: 在这已经运行,背景设置好之后,我想调用一个checkerlint方法标识符,它将检查其他打开的平铺并相应地更改背景 此方法需要单独运行,因为只有在onClick完成后才会显示背景,并且我需要在checker方法将其更改为其他内容之前显示一段短时间的预定背景 我怎样才能做到这一点呢?你试过了吗 View.OnClickListener imgButton0Handler0
我怎样才能做到这一点呢?你试过了吗
View.OnClickListener imgButton0Handler0 = new View.OnClickListener() {
int identifier=0;
public void onClick(View v) {
//check if tile is found and return if it is
if(isFound[identifier]==true) return;
//set tile as open
checkField[identifier]=1;
//set background on predetermined
button0.setBackgroundResource(tiles[identifier]);
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
// This method will be executed once the timer is over
// Start your app main activity
checker(identifier) // your method call
}
}, 3000); // 3 second
}
};
View.OnClickListener imgButton0Handler0 = new View.OnClickListener() {
int identifier=0;
public void onClick(View v) {
//check if tile is found and return if it is
if(isFound[identifier]==true) return;
//set tile as open
checkField[identifier]=1;
//set background on predetermined
button0.setBackgroundResource(tiles[identifier]);
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
// This method will be executed once the timer is over
// Start your app main activity
checker(identifier) // your method call
}
}, 3000); // 3 second
}
};