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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T10:35:24+00:00 2026-05-30T10:35:24+00:00

My application contains many Dialog windows. It has gotten to the point that the

  • 0

My application contains many Dialog windows. It has gotten to the point that the source seems overwhelming. I am looking for opinions about the best way to segregate Dialog source. I am relatively new to Java, so I am assuming that I can put them in a separate class. However, the exact way to do this in Android alludes me. May someone point me in the right direction?

  • 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-30T10:35:26+00:00Added an answer on May 30, 2026 at 10:35 am

    u can create dialogue by extending dialogue as follows
    1. Create a Layout.xml for customDialog
    Create a new layout which contains the view. in this example i have used edittext and button.

    <?xml version="1.0" encoding="utf-8"?>
    

    <EditText android:id="@+id/EditText01" android:layout_height="wrap_content" android:text="Enter your name" android:layout_width="250dip"></EditText>
    
    <Button android:id="@+id/Button01" android:layout_width="wrap_content"
        android:layout_height="wrap_content" android:text="click"></Button>
    

    1. Create a Custom Dialog Class.
      a. Create a class extends the dialog class
      b. Create a Event Handler Interface as a member
      c. Use the custom layout in onCreate Method.

      public class MyCustomDialog extends Dialog {
      
      public interface ReadyListener {
          public void ready(String name);
      }
      
      private String name;
      private ReadyListener readyListener;
      EditText etName;
      
      public MyCustomDialog(Context context, String name, 
              ReadyListener readyListener) {
          super(context);
          this.name = name;
          this.readyListener = readyListener;
      }
      
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.mycustomdialog);
          setTitle("Enter your Name ");
          Button buttonOK = (Button) findViewById(R.id.Button01);
          buttonOK.setOnClickListener(new OKListener());
          etName = (EditText) findViewById(R.id.EditText01);
      }
      
      private class OKListener implements android.view.View.OnClickListener {
          @Override
          public void onClick(View v) {
              readyListener.ready(String.valueOf(etName.getText()));
              MyCustomDialog.this.dismiss();
          }
      }
      

      }

    2. Create a MainActivity and Implement the CustomDialog

      public class MainActivity extends Activity {
      /** Called when the activity is first created. */
      @Override
      public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.main);
      MyCustomDialog myDialog = new MyCustomDialog(this, “”,
      new OnReadyListener());
      myDialog.show();
      }
      private class OnReadyListener implements MyCustomDialog.ReadyListener {
      @Override
      public void ready(String name) {
      Toast.makeText(MainActivity.this, name, Toast.LENGTH_LONG).show();
      }
      }
      }

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

Sidebar

Related Questions

We have a Windows Forms application that contains thousands of forms. Many of these
I have an application that contains many controls on a panel, each with its
In a C# Winforms (3.5) application I have added a class that contains many
I have a .NET application that contains a checkbox (System.Windows.Forms.Checkbox). This component (WindowsForms10.BUTTON.app.0.378734a1) is
I have an application that generates a lengthy Xml output file which contains many
In my C# windows application solution I've got a Reporting project which contains many
I'm working on an application that contains many JFrames, with the amateurish result that
In my Winforms application I have a toolbar that contains many items (buttons with
In my application, I need to store and transmit data that contains many repeating
Hi my application contains many activities. I create some action-items that display to the

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.