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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T08:09:47+00:00 2026-05-30T08:09:47+00:00

I am trying to show a customizable dialog. This dialog contains 3 edittext and

  • 0

I am trying to show a customizable dialog. This dialog contains 3 edittext and one timepicker. I want to show this dialog when I press a button in the screen. I looked at google tutorial and try to write the code. However, when I used the root layout in the inflater as the layout which is being pressed button in it, it adds the dialog under the button. When I used the root layout in the dialog_xml the button does not work.
The part of that code is under below. Do you have any idea How can i do this in right way?

    Button ekleButton;
    public void onCreate(Bundle savedInstanceState) {
       super.onCreate(savedInstanceState);
       setContentView(R.layout.haphatirlatici);

       // After creating the activity setting other things for running
       ekleButton = (Button) findViewById(R.id.EkleButton);
       ekleButton.setOnClickListener(new View.OnClickListener() {   
       public void onClick(View v) {
            // TODO Auto-generated method stub
            // Dialog icin yerlesimler

        AlertDialog.Builder builder;
        AlertDialog alertDialog;

        Context mContext = getApplicationContext();
        LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(LAYOUT_INFLATER_SERVICE);
        View layout = inflater.inflate(R.layout.ekle_dialog,
                                       (ViewGroup) findViewById(R.id.Ekle_Layout));

        builder = new AlertDialog.Builder(mContext);
        builder.setView(layout);
        alertDialog = builder.create();

        }
    });

After this one I edit the code and add two buttons. I want to get the result of the alert dialog to the activity that is seen.
The code that I write is on below.

public class HapHatirlatici extends Activity{

Button ekleButton;
boolean eklendiMi;
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.haphatirlatici);

    // After creating the activity setting other things for running
    ekleButton = (Button) findViewById(R.id.EkleButton);
    eklendiMi = false;
    ekleButton.setOnClickListener(new View.OnClickListener() {
    public void onClick(View v) {
        // TODO Auto-generated method stub

        View layout = getLayoutInflater().inflate(R.layout.ekle_dialog, null);                               
        AlertDialog.Builder builder = new AlertDialog.Builder(HapHatirlatici.this);
        builder.setPositiveButton(R.string.ekle,new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int id) {
                eklendiMi = true;
           }
        });
        builder.setNegativeButton(R.string.vazgec, new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int id) {
                eklendiMi = false;
           }
        });
        builder.setView(layout);
        AlertDialog alertDialog = builder.create();
        alertDialog.setTitle("Ilac Ekleme");
        alertDialog.show();


        }
    });
}
public boolean databaseEkle()
{
    boolean sonuc = false;
    return sonuc;
}

 }
  • 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-30T08:09:49+00:00Added an answer on May 30, 2026 at 8:09 am

    You forgot the alertDialog.show(); to actually display the dialog you just built.

    Also, your code can be simplified:

    Button ekleButton;
    public void onCreate(Bundle savedInstanceState) {
       super.onCreate(savedInstanceState);
       setContentView(R.layout.haphatirlatici);
    
       // After creating the activity setting other things for running
       ekleButton = (Button) findViewById(R.id.EkleButton);
       ekleButton.setOnClickListener(new View.OnClickListener() {   
           public void onClick(View v) { 
               View layout = getLayoutInflater().inflate(R.layout.ekle_dialog, null);                               
               AlertDialog.Builder builder = new AlertDialog.Builder(YourActivityClass.this);
               builder.setView(layout);
               AlertDialog alertDialog = builder.create();
    
               // this is what you forgot:
               alertDialog.show();
           }
        });
    }
    

    Of course, replace YourActivityClass with your actual activity name.

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

Sidebar

Related Questions

I'm trying to show a dialog with a google map, when the user clicks
I'm trying to show a simple dialog like this: if (!aboutDialog) aboutDialog = new
i'm trying to show MBProgressHUD when a button is clicked and at the end
I am trying to show a progress overview at the top of the one
I am trying to show the user's location obtained using geolocation API on google
I am trying to show a alertdialog but i keep getting this error 01-24
I am trying to show the session value by drop down list. This is
I'm trying to show a tooltip regardless of a buttons state, but this does
So I am trying to show x amount of images from google using the
I'm trying to show all images from a selected category on screen. Which is

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.