私は別のダイアログのポップアップのポップアップを含むアプリケーションを作成しました。私が書いたコードがされています。今、私の質問は、各ダイアログのために、私は別のonclick
機能を必要とするということであるAlertDialogを制御する方法
if (lDiffFromToday >= 0 && lDiffFromToday <= DeclareVariable.CYCLE_MAX_LENGTH)
{
AlertDialog.Builder alrtStartMonitoring = new AlertDialog.Builder(this);
alrtStartMonitoring.setTitle(" Start Monitoring");
alrtStartMonitoring.setMessage("Set start date of cycle as"+" "+sdFormatter.format(dtSelDate));
alrtStartMonitoring.setPositiveButton("Yes", this);
AlertDialog alert = alrtStartMonitoring.create();
alert.show();
}
else if (dtSelDate.getTime()> dtStartDate.getTime() && dtSelDate.getTime() <= currentDate.getTime() && !bCycleStopped)
{
long lDiffFromStart =dtSelDate.getTime()-dtStartDate.getTime();
lDiffFromStart=lDiffFromStart/(1000 * 60 * 60 * 24);
if (lDiffFromStart >= DeclareVariable.CYCLE_MIN_LENGTH)
{
bActionOk = true;
AlertDialog.Builder alrtStartMonitoring = new AlertDialog.Builder(this);
alrtStartMonitoring.setTitle(" Confirm New Cycle");
alrtStartMonitoring.setMessage("Set start date of cycle as" + " " + sdFormatter.format(dtSelDate));
alrtStartMonitoring.setPositiveButton("Yes", this);
AlertDialog alert = alrtStartMonitoring.create();
alert.show();
}
}
public void onClick(DialogInterface dialog, int id)
{
CycleManager.getSingletonObject().setHistoryDate(dtSelDate);
int iStopStartCount = CycleManager.getSingletonObject().getStopStartCount();
if(iStopStartCount>0)
CycleManager.getSingletonObject().setStopStartDate(dtSelDate, iStopStartCount);
displayDay();
}
が、私は別のonclick関数を書くとき、私の場合には、競合が存在することになるより。私は各ダイアログの中にonclick
関数を書くことで問題を解決できるかもしれませんが、その場合は私の変数をfinalとして宣言しなければならないので、私が使ったダイアログごとに関数onclick
を書くことでどうすればいいですか?
コードを正しくフォーマットしてください。 – mohamede1945
申し訳ありませんが、私に答えを教えてください。 – AndroidDev