Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6093309
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T12:32:42+00:00 2026-05-23T12:32:42+00:00

I have created an app which includes popups of different dialogs. Here is my

  • 0

I have created an app which includes popups of different dialogs.

Here is my code:

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();
}

Now my question is that for each dialog I need different onClick functions but in my case when I write another onClick function then there will be conflict. I know by writing the onClick function inside each dialog may solve the problem but in that case, I have to declare my variables as final so how can I do it by writing onClick function outside for every dialog I used.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T12:32:43+00:00Added an answer on May 23, 2026 at 12:32 pm

    Another solution will be to make the AlertDialog instances members of your class. Then in the OnClick method:

    public void onClick(DialogInterface dialog, int id) 
    {
      if (dialog == m_Dialog1)
      {
        // server dialog 1
      }
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created an app which allows users to buy non-consumable content. The retrieving-ids-payment-process
I have created an app which allows users to buy non-consumable content. The retrieving-ids-payment-process
I have created an app in which I have used achartengine to construct the
I have created an app that uses NSTimer, which gets triggered each second. My
I have created a library which reads the app.config file and gets the type
I have created an animated game app, In which I am using NSTimer to
We have created a facebook-app which contains a fb:comment field. We have included the
I have created a quiz app which emails the user the results. I want
I have an ad-hoc deployment of my iOS game, which includes in-app purchase. It
We have created an iOS app for a client, which we would like them

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.