actionbarsherlock にメニュー項目があるプログラムを作成しています。今、私はユーザーがそのメニューを 1 日に 1 回クリックするようにしたいと考えています。どうすればこれを達成できますか? これが私がこれまでに持っているものです:
int hour = today.get(Calendar.HOUR_OF_DAY);
if (hour < 24) {
try {
if (gotGenders.contentEquals("Male")) {
AlertDialog.Builder alertDialog = new AlertDialog.Builder(
Monitor.this);
alertDialog.setTitle(gotNames);
alertDialog.setMessage("You are currently burning "
+ caloriesForMen() + " calories per hour");
alertDialog.setPositiveButton("Save",
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog,
int which) {
// TODO Auto-generated method stub
}
});
alertDialog.setNegativeButton("Discard",
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog,
int which) {
// TODO Auto-generated method stub
dialog.dismiss();
}
});
alertDialog.setCancelable(false);
showAlertDialog = alertDialog.create();
showAlertDialog.show();
}
else if (gotGenders.contentEquals("Female")) {
AlertDialog.Builder alertDialog = new AlertDialog.Builder(
Monitor.this);
alertDialog.setTitle(gotNames);
alertDialog.setMessage("You are currently burning "
+ caloriesForWomen() + " calories per hour");
alertDialog.setPositiveButton("Save",
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog,
int which) {
// TODO Auto-generated method stub
// dialog.dismiss();
}
});
alertDialog.setNegativeButton("Discard",
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog,
int which) {
// TODO Auto-generated method stub
dialog.dismiss();
}
});
alertDialog.setCancelable(false);
showAlertDialog = alertDialog.create();
showAlertDialog.show();
count = 1;
}
} catch (Exception ex) {
ex.printStackTrace();
AlertDialog.Builder errorDialog = new AlertDialog.Builder(
Monitor.this);
errorDialog.setTitle("No User Selected!");
// errorDialog.setMessage("You are currently burning " +
// caloriesForWomen() + " per hour");
errorDialog.setPositiveButton("OK",
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog,
int which) {
// TODO Auto-generated method stub
dialog.dismiss();
}
});
errorDialog.setCancelable(false);
errorAlertDialog = errorDialog.create();
errorAlertDialog.show();
}
} else {
count = 0;
AlertDialog.Builder waitDialog = new AlertDialog.Builder(
Monitor.this);
waitDialog.setTitle("Wait after the day is over");
waitDialog.setPositiveButton("OK",
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
// TODO Auto-generated method stub
dialog.dismiss();
}
});
waitDialog.setCancelable(false);
waitAlertDialog = waitDialog.create();
waitAlertDialog.show();
}
これにより、メニューを複数回選択できるようになります。1 日に 1 回のクリックに制限するにはどうすればよいですか? どんな助けでも感謝します。