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

  • SEARCH
  • Home
  • 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 7643955
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T09:34:19+00:00 2026-05-31T09:34:19+00:00

Hi I am popping up dialog to take comments from user. And returning a

  • 0

Hi I am popping up dialog to take comments from user. And returning a value according to that. That “rcomment” is a global variable. And it returns null. This is not working. What am I doing wrong ?

 public String getDoNotBoardDialog(final int groupposition)
     {
         final Dialog dia = new Dialog(this);
         dia.requestWindowFeature(Window.FEATURE_NO_TITLE); 
         dia.setContentView(R.layout.donotboard);
         final EditText donotedit = (EditText) dia.findViewById(R.id.donotboardcomment);
         donotedit.setText(""); 

         Button button1 = (Button) dia.findViewById(R.id.donotboardbutton);
         button1.setOnClickListener(new OnClickListener() {
             public void onClick(View v) {
                 r =  donotedit.getText().toString();
                 String boardingComment = getString(R.string.donotboard) + " " + r;
                 PostCommentForAC(groupposition, boardingComment);
                 Intent intent = new Intent(getBaseContext(), TestExList.class); 
                 intent.putExtra("EmpID", empid);
                 startActivity(intent);
                 rcomment = "true";
                 dia.cancel();
        }
       });
          Button button2 = (Button) dia.findViewById(R.id.boardbutton);
          button2.setOnClickListener(new OnClickListener() {
              public void onClick(View v) {
                rcomment = "false";
            dia.cancel();
        }
       });
      dia.show();
    return rcomment;
     }
  • 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-31T09:34:21+00:00Added an answer on May 31, 2026 at 9:34 am

    Edit: dont use below code. It will kill your app (ANR).

    You would have to wait before you can return something. A quick (but really dirty) solution would be to add some wait/notify mechanism like so: (written blind so might contain some errors).

    public String getDoNotBoardDialog(final int groupposition) {
         // some Object to wait on
         final Object waitOnMe = new Object();
         final Dialog dia = new Dialog(this);
         dia.requestWindowFeature(Window.FEATURE_NO_TITLE); 
         dia.setContentView(R.layout.donotboard);
         final EditText donotedit = (EditText) dia.findViewById(R.id.donotboardcomment);
         donotedit.setText(""); 
    
         Button button1 = (Button) dia.findViewById(R.id.donotboardbutton);
         button1.setOnClickListener(new OnClickListener() {
             public void onClick(View v) {
                 r =  donotedit.getText().toString();
                 String boardingComment = getString(R.string.donotboard) + " " + r;
                 PostCommentForAC(groupposition, boardingComment);
                 Intent intent = new Intent(getBaseContext(), TestExList.class); 
                 intent.putExtra("EmpID", empid);
                 startActivity(intent);
                 rcomment = "true";
                 dia.cancel();
                // stop waiting.
                synchronized(waitOnMe) {
                    waitOnMe.notify();
                }
        }
       });
          Button button2 = (Button) dia.findViewById(R.id.boardbutton);
          button2.setOnClickListener(new OnClickListener() {
              public void onClick(View v) {
                rcomment = "false";
            dia.cancel();
            // stop waiting.
            synchronized(waitOnMe) {
                waitOnMe.notify();
            }
        }
       });
      dia.show();
      // this wait's until someone calls notify
      synchronized (waitOnMe) {
          try {
              waitOnMe.wait();
          } catch (InterruptedException e) {}
      }
    return rcomment;
     }
    

    It’s problematic though. You could miss the notify() and thus never stop waiting (e.g. when you close the dialog via the “back” button). A much cleaner and safer solution would be to use some Callback mechanism (you call some method in your program from each onClick) to get a value from the dialog.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've seen a few Windows 7 applications popping up around the web that take
I am popping up a dialog box when someone tries to navigate away from
I see .copyarea.db files popping up in my ClearCase snapshot directories. I understand that
I have here a bubble popping game where bubbles fall from top of the
I am trying to get the Jquery UI modal dialog to take over after
I have some simple code for popping up a dialog-like thing over part of
Minimal example dialog: <p:dialog header=Test Dialog widgetVar=testDialog> <h:form> <p:inputText value=#{mbean.someValue}/> <p:commandButton value=Save onsuccess=testDialog.hide() actionListener=#{mbean.saveMethod}/>
I need to create a dialog from a thread. Im loading a nib file
On our site: http://indafoto.hu the confirm dialog started popping up last day, what can
The following dialog window keeps popping on my computrer when starting Click-Once published application

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.