Inflated layout to alertdialog doesn't work
<p>I have the following method where I must confirm the user's password before he is allowed to access the Setup menu. To do so, I make him login again because Parse (my cloud storage) doesn't allow me to confirm passwords. So far so good. The problem is when I inflate the <code>view</code> to my <code>AlertDialog</code> to use a custom <code>button</code> and <code>EditText</code>. You can see in my code below that I have commented the <code>Button</code> section, because when I try to get the <code>onClickListener</code> it doesn't work. It just does nothing. So I'm currently using the <code>alertDialogPositiveButton</code> and it's ok. The second problem and the real one is that I cannot retrieve the data insert into the <code>editText</code>. The <code>SUpassword3</code>is always equals to blank, not <code>null</code>. Can someone please help?</p>

<p>method:</p>

<pre><code>public void confirmPassword(){

        final LayoutInflater inflateSetup = getLayoutInflater();

        AlertDialog.Builder alertSetup = new AlertDialog.Builder(this);
        alertSetup.setView(inflateSetup.inflate(R.layout.inflate_setup, null));
        alertSetup.setPositiveButton("Confirm", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                System.out.println("User has clicked the [confirm] button");
                View viewInflate_setup = inflateSetup.inflate(R.layout.inflate_setup, null);
                edtPassword3 = (EditText)viewInflate_setup.findViewById(R.id.edtPassword3);
                SUpassword3 = edtPassword3.getText().toString();

                final ParseUser beforeConfirmPassword = ParseUser.getCurrentUser();
                ParseUser.logInInBackground(beforeConfirmPassword.getUsername(), SUpassword3, new LogInCallback() {
                    @Override
                    public void done(ParseUser parseUser, ParseException e) {
                        if(e==null){
                            //password confirmed, logout last user and go to next setup
                            System.out.println("Password [" +SUpassword3+ "] and user [" +beforeConfirmPassword.getUsername()+ "] confirmed, logout last user and go to setup");
                            beforeConfirmPassword.logOut();
                        }else{
                            //passwords don't match
                            System.out.println("Password don't match: [" +SUpassword3 + "] USER [" +beforeConfirmPassword.getUsername()+ "]");
                        }
                    }
                });
            }
        });
        final AlertDialog dialogSetup = alertSetup.create();
        dialogSetup.show();


/**
        btnConfirmPassowod = (Button)viewInflate_setup.findViewById(R.id.btnConfirm);
        btnConfirmPassowod.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(final View v) {
                System.out.println("User has clicked the [confirm] button");
                final ParseUser beforeConfirmPassword = ParseUser.getCurrentUser();
                ParseUser.logInInBackground(beforeConfirmPassword.getUsername(), SUpassword3, new LogInCallback() {
                    @Override
                    public void done(ParseUser parseUser, ParseException e) {
                        if(e==null){
                            //password confirmed, logout last user and go to next setup
                            System.out.println("Password confirmed, logout last user and go to setup");
                            beforeConfirmPassword.logOut();
                        }else{
                            //passwords don't match
                            dialogSetup.dismiss();
                            Snackbar.make(v, "Wrong password, try again.", Snackbar.LENGTH_LONG)
                                    .setAction("Action", null).show();
                        }
                    }
                });
            }
        }); */
    }
</code></pre>

<p>inflate_setup.xml(the xml file I inflate on the alertDialog)</p>

<pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:layout_width="match_parent"
    android:layout_height="match_parent"&gt;

    &lt;EditText
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:inputType="textPassword"
        android:ems="10"
        android:id="@+id/edtPassword3"
        android:layout_gravity="center_horizontal"
        android:hint="@string/EN_txt.confirmPassword"
        /&gt;
&lt;Button
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:text="New Button"
    android:id="@+id/btnConfirm"
    android:layout_gravity="center_horizontal" /&gt;

&lt;/LinearLayout&gt;
</code></pre>

<p>Final version(working):</p>

<pre><code>public void confirmPassword(){

        final LayoutInflater inflateSetup = getLayoutInflater();
        final View viewInflate_setup = inflateSetup.inflate(R.layout.inflate_setup, null);

        AlertDialog.Builder alertSetup = new AlertDialog.Builder(this);
        alertSetup.setView(viewInflate_setup);
        alertSetup.setPositiveButton("Confirm", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                System.out.println("User has clicked the [confirm] button");

                edtPassword3 = (EditText)viewInflate_setup.findViewById(R.id.edtPassword3);
                SUpassword3 = edtPassword3.getText().toString();
</code></pre>

<p>...</p>