You can do this with a Dialog box and a custom layout with the
EditText and button elements defined inside it. Then attach a
TextChanged listener to the EditText and enable/disable buttons as
appropriate.

mDialog = new Dialog(this);
mDialog.setCancelable(true);
mDialog.setContentView(R.layout.dialoginput);

Where dialoginput.xml would be something like:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/
android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    >
        <EditText
                android:id="@+id/show_input"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_centerHorizontal="true"
        />

        <LinearLayout
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_below="@id/show_input"
                android:layout_centerHorizontal="true"
        >
                <Button
                        android:id="@+id/btn_ok"
                        android:layout_width="60sp"
                        android:layout_height="wrap_content"
                        android:text="OK"
                />

                        <Button
                        android:id="@+id/btn_cancel"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="Cancel"
                />
        </LinearLayout>

</RelativeLayout>

Have a look at
http://code.google.com/android/reference/android/widget/TextView.html#addTextChangedListener(android.text.TextWatcher)

On Feb 13, 8:23 am, Peter Sankauskas <[email protected]> wrote:
> I would like to bring up an old post I have found without a solution:
>
> http://groups.google.com/group/android-developers/browse_thread/threa...
>
> It seems Gil and I both want to do the same thing: implement an
> AlertDialog with positive/negative buttons, and embed an EditView in
> it that disables the OK button if no text has been entered.
>
> Has anyone found a neat way of doing this?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to