我正在研究自定义相机应用程序,但我不知道如何在自定义中实现计时器选项请帮助我谢谢.. 这是下面的代码
timer.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
final CharSequence[] items = {"2 sec", "5 sec", "10 sec"};
AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
builder.setTitle("Timer");
builder.setItems(items, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int item) {
if (items[item].equals("2 sec")) {
} else if (items[item].equals("5 sec")) {
} else if (items[item].equals("10 sec")) {
}
}
});
builder.show();
}
});
答案 0 :(得分:0)
您可以在if-else
new CountDownTimer(2000, 1000) {
//just replace 2000 for 5000 to get 5 seconds
public void onTick(long millisUntilFinished) {
mTextField.setText("seconds remaining: " + millisUntilFinished / 1000);
//here you can have your logic to set text to edittext
}
public void onFinish() {
mTextField.setText("done!");
}
}.start();