다른 대화 상자의 팝업 팝업을 포함하는 응용 프로그램을 만들었습니다. 내가 작성한 코드는 다음과 같습니다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
함수를 작성하여 문제를 해결할 수는 있지만 그 경우에는 최종 변수로 선언해야하므로 어떻게 모든 대화 상자에서 함수를 작성하여 수행 할 수 있습니까?
코드를 올바르게 포맷하십시오. – mohamede1945
죄송합니다. 제발 대답을 말해주십시오. – AndroidDev