0

I have an activity that launches a series of popupWindows via a LayoutInflater. One of them has a bunch of EditTexts in it, and for some reason I cannot get the soft keyboard to launch when they are focused. However, if I switch it from a popupWindow to an alertDialogue.Builder, it works just fine.

Why is this, and how can I get it to work as a popupWindow?

AlertDialogue code:

AlertDialog.Builder pop_up = new AlertDialog.Builder(this);
pop_up.setView(this.getLayoutInflater().inflate(R.layout.signup_layout, null));
pop_up.show();

PopupWindow code:

LayoutInflater layoutInflater = (LayoutInflater)getBaseContext()
    .getSystemService(LAYOUT_INFLATER_SERVICE);
View popupView = layoutInflater.inflate(R.layout.signup_layout, null);
PopupWindow popupWindow = new PopupWindow(popupView, LayoutParams.MATCH_PARENT,
    LayoutParams.MATCH_PARENT);
popupWindow.showAtLocation(view, 1, 0, 0);

and the xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="#C417375E"
    android:gravity="center"
    android:orientation="vertical"
     >

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@drawable/popup_background"
        android:focusableInTouchMode="true"
        android:orientation="vertical"
        android:padding="15dp" >

        <Button
            android:id="@+id/back_button"
            android:layout_width="150dp"
            android:layout_height="40dp"
            android:background="@drawable/popup_background"
            android:text="Back"
            android:textColor="#ffffff"
            android:textSize="20sp" />

        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:paddingLeft="4dp"
            android:text="Email or Phone Number"
            android:textColor="#ffffff"
            android:textSize="30sp" />

        <EditText
            android:id="@+id/email_textField"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:ems="10"
            android:inputType="textEmailAddress" />

        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:paddingLeft="4dp"
            android:text="Choose a Password"
            android:textColor="#ffffff"
            android:textSize="30sp" />

        <EditText
            android:id="@+id/password_textField"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:ems="10"
            android:inputType="textPassword" />

        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:paddingLeft="4dp"
            android:text="Confirm Password"
            android:textColor="#ffffff"
            android:textSize="30sp" />

        <EditText
            android:id="@+id/confirm_password_textField"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:ems="10"
            android:inputType="textPassword" />

        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:paddingLeft="4dp"
            android:text="Zip Code(optional)"
            android:textColor="#ffffff"
            android:textSize="30sp" />

        <EditText
            android:id="@+id/zipcode_textField"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:ems="10"
            android:inputType="number" />

        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:paddingLeft="4dp"
            android:text="Your First Name (optional)"
            android:textColor="#ffffff"
            android:textSize="30sp" />

        <EditText
            android:id="@+id/name_textField"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:ems="10"
            android:inputType="textPersonName" />

        <Button
            android:id="@+id/done_button"
            android:layout_width="150dp"
            android:layout_height="40dp"
            android:layout_gravity="center"
            android:layout_marginTop="10dp"
            android:background="@drawable/popup_background"
            android:onClick="onClick_thanksForSigningUp"
            android:text="Done"
            android:textColor="#ffffff"
            android:textSize="20sp" />
    </LinearLayout>

</LinearLayout>
  • i think you didnt link your edittext to java......using "findviewbyid"....try it..might work... – ASP Jun 17 '13 at 03:48
  • try running after removing this line 'android:focusableInTouchMode="true"' from your linearlayout xml code. – ASP Jun 18 '13 at 04:21
  • unfortunately it still doesn't work. It looks like I'll be moving all of my code to dialogs. – user1623346 Jun 20 '13 at 13:18

1 Answers1

0

Try like this.....for all your Edittexts.

EditText edt = (EditText) popupView.findviewbyid(R.id.name_textField);

Hope it works. Thanks.

ASP
  • 3,645
  • 1
  • 31
  • 45
  • That just allows me to access the EditText from the java code. Adding that line doesn't change the behavior of the keyboard. Is there a method call I need to make on the EditText to make the keyboard appear when using a popup? If so, why don't I have to make it from the AlertDialog? – user1623346 Jun 17 '13 at 13:47