AlertDialog Input Text

Put your problem here if it does not fit any of the other categories.

AlertDialog Input Text

Postby soclose » Thu Jun 10, 2010 4:04 am

Hi,

I'd like to use AlertDialog as a Login or pin code or password dialog. Here is my code -

Code: Select all
    AlertDialog.Builder alert = new AlertDialog.Builder(this);                 
    alert.setTitle("Login"); 
    alert.setMessage("Enter Pin :");               

    // Set an EditText view to get user input   
    final EditText input = new EditText(this);
    alert.setView(input);

    alert.setPositiveButton("Ok", new DialogInterface.OnClickListener() { 
    public void onClick(DialogInterface dialog, int whichButton) { 
        String value = input.getText().toString();
        Log.d( TAG, "Pin Value : " + value);
        return;                 
       } 
     }); 

    alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {

        public void onClick(DialogInterface dialog, int which) {
            // TODO Auto-generated method stub
            return;   
        }
    });
     alert.show();


How to code that all input text will appear like ' *** ' - asterisk
soclose
Experienced Developer
Experienced Developer
 
Posts: 80
Joined: Sun Apr 25, 2010 8:38 am

Top

Re: AlertDialog Input Text

Postby soclose » Thu Jun 10, 2010 8:14 am

I use LayoutInflater. now it worked.
soclose
Experienced Developer
Experienced Developer
 
Posts: 80
Joined: Sun Apr 25, 2010 8:38 am

Re: AlertDialog Input Text

Postby soclose » Fri Jun 11, 2010 9:52 am

I can't get my pin code value although it shows into asterisk. my code is below

Code: Select all
    private void accessPinCode_2()
{
    LayoutInflater factory = LayoutInflater.from(this);
    final View textEntryView = factory.inflate(R.layout.dialog_login, null);
    AlertDialog.Builder alert = new AlertDialog.Builder(this);                 
    alert.setTitle("Login"); 
alert.setMessage("Enter Pin :");               
alert.setView(textEntryView);

    alert.setPositiveButton("Ok", new DialogInterface.OnClickListener() { 
    public void onClick(DialogInterface dialog, int whichButton) { 
        //String value = input.getText().toString();
        EditText mUserText;
        mUserText = (EditText) textEntryView.findViewById(R.id.txt_password);
        String strPinCode = mUserText.getText().toString();
        Log.d( TAG, "Pin Value : " + strPinCode);
        return;                 
       } 
     }); 

    alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {

        public void onClick(DialogInterface dialog, int which) {
            // TODO Auto-generated method stub
            return;   
        }
    });
            alert.show();   }}


dialog_login.xml
Code: Select all
<?xml version="1.0" encoding="utf-8"?><EditText xmlns:android="http://schemas.android.com/apk/res/android"
        id="@+id/txt_password"
         android:password="true"
         android:layout_height="wrap_content"
         android:layout_width="250px"
         android:layout_centerHorizontal="true"
         android:layout_below="@+id/password_text"
         android:singleLine="true" />

how to solve?
soclose
Experienced Developer
Experienced Developer
 
Posts: 80
Joined: Sun Apr 25, 2010 8:38 am

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: No registered users and 20 guests