Return value from onClick() In returner method
<p>I'm have some problem about return value from onClick method In DialogInterface.OnClickListener().
Can I return string form edittext in dialog.When I call this method in one time without assign it to other var later.</p>

<pre><code>//Exam Code
public String getPhoneNumber(){
        String phoneNumber = "";

        AlertDialog.Builder alert = new AlertDialog.Builder(context);
        alert.setTitle("Please input phone number");
        alert.setMessage("ex. 66898765432");
        final EditText phoneNumberEditText = new EditText(context);
        phoneNumberEditText.setInputType(InputType.TYPE_CLASS_NUMBER);
        alert.setView(phoneNumberEditText);


        alert.setPositiveButton("Submit",new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int whichButton) {
                    phoneNumber = phoneNumberEditText.getText().toString();
                {
        });

        alert.show();

        return phoneNumber;
}
</code></pre>

<p>in exam code it will return "" back .How I solve this problem.</p>

<p>Thank for all answer :)</p>
