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 7818339
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T06:32:45+00:00 2026-06-02T06:32:45+00:00

I want main activity to wait while dialog box is excuted. I tried this.wait();

  • 0

I want main activity to wait while dialog box is excuted. I tried this.wait(); in main activity but it gives exception. This is all crossed my mind so I am here to ask for help :). Thank you in advance
Any Help Will Be Appreciated

public class MyDailogTestActivity extends Activity {
    /** Called when the activity is first created. */
    String Xvalue,Yvalue;
    TextView TextViewString;    
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        Button ShowDialog = (Button) findViewById(R.id.ShowDialog);
        TextViewString = (TextView) findViewById(R.id.ShowDialogText);      
        ShowDialog.setOnClickListener(new OnClickListener(){
            public void onClick(View arg0) {
                // TODO Auto-generated method stub
                Dialog MyDialog = MyDailog();
                MyDialog.show();
                // I WANT THIS TO EXECUTE AFTER BELOW MENTIONED CODE
                TextViewString.setText(Xvalue + Yvalue);
            }

        });
    }

    private Dialog MyDailog(){
        LayoutInflater factory = LayoutInflater.from(this);
        final View textEntryView = factory.inflate(R.layout.my_dialog, null);
        return new AlertDialog.Builder(MyDailogTestActivity.this)
        .setTitle("Enter Value")
        .setView(textEntryView)
        .setPositiveButton("Oky", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int whichButton) {
                // THIS TO BE EXECUTE FIRST       
                Xvalue = "This ";
                Yvalue = "and That";                
                /* User clicked OK so do some stuff */
            }
        })
        .setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int whichButton) {
                /* User clicked cancel so do some stuff */
            }
        })
        .create();        
    }

}

This is images of this project while executing

http://imageshack.us/photo/my-images/220/11696639.jpg/
In this image you can see Hello World unchanged. I am trying to reflect the change in hello world TextView.

http://imageshack.us/photo/my-images/338/27833231.jpg/
Now in this image. When I hit show dialog it carry on executing the next code TextViewString.setText(Xvalue + Yvalue);
in which it shows the value null
now I want it to wait for dialog box to finish code in which Xvalue and Yvalue will have the value “This n That” by this code

Xvalue = "This ";
Yvalue = "and That";  
  • 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-06-02T06:32:46+00:00Added an answer on June 2, 2026 at 6:32 am

    Move this line:

    TextViewString.setText(Xvalue + Yvalue);
    

    to your positive button click listener like this:

    public void onClick(DialogInterface dialog, int whichButton) {
        // THIS TO BE EXECUTE FIRST    
        Xvalue = "This ";
        Yvalue = "and That";                
        /* User clicked OK so do some stuff */
        TextViewString.setText(Xvalue + Yvalue);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In my main activity, i call a dialog which is cancelable. I show this
I'm trying to do blog application and I want main page to have this
So I want my main menu to have a ccMenu. I tried exploring with
I want to make this specialized w/o changing main. Is it possible to specialize
In my app, I want it to go to my main activity when user
I am using Button in main Activity. When i clicked this button it will
Main Activity with button I want changed. It should import what the user put
How to change main activity at application startup in Android? I want to implement
I have a ListActivity as my main activity. I want to be able to
I created a new MapActivity class MapProba . From main Activity I want to

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.