Question

i have a EditText in a PopupWindow, when the PopupWindow comes up cursor in EditText is visble but i cannot edit its text.

my codes:

popupwindolayout.xml:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/wordfragd2">

    <EditText
        android:id="@+id/noteedit_popup_textview"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:ems="10"
        android:inputType="textMultiLine"
        android:text="my notes"
        android:background="@drawable/wordfragd1"
        android:layout_marginTop="10dp"
        android:layout_marginLeft="10dp"
        android:layout_marginRight="10dp"
        android:layout_marginBottom="1dp"
        android:padding="10dp"
        android:editable="true">

        <requestFocus />
    </EditText>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"  
        android:layout_below="@+id/noteedit_popup_textview"
        android:layout_marginTop="1dp"
        android:layout_marginLeft="10dp"
        android:layout_marginRight="10dp"
        android:layout_marginBottom="10dp"
        android:orientation="horizontal"
        android:weightSum="2"
        >

        <Button
            android:id="@+id/done_popup_button"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"       
            android:text="Done"
            android:layout_weight="1" 
            android:background="@drawable/wordfragd1"
            android:layout_marginRight="1dp"
            />

        <Button
            android:id="@+id/cancel_popup_button"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Cancel"
            android:layout_weight="1"
            android:background="@drawable/wordfragd1"
            android:layout_marginRight="1dp" />
    </LinearLayout>

</RelativeLayout>

Javas for popupwindow:

PopupWindow editnote_popup;

                LayoutInflater inflater = (LayoutInflater) getActivity()
                         .getSystemService(Context.LAYOUT_INFLATER_SERVICE);

                View view=inflater.inflate(R.layout.wordnoteedit_popup,
                         null);

                editnote_popup=new PopupWindow(view, LayoutParams.WRAP_CONTENT,  LayoutParams.WRAP_CONTENT);
                 editnote_popup.setContentView(view);
                 editnote_popup.showAtLocation(view, Gravity.CENTER, 0, 0);

I'm working with fragments. I've displayed a popup window on button click. Inside popup window, I've added edit text through XML. While running, I cant type in that edit text., but my cursor is visible and blinking.

any idea?

Was it helpful?

Solution

Add true in this line editnote_popup=new PopupWindow(view, LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); to make it focusable.

It wiil be:

editnote_popup=new PopupWindow(view, LayoutParams.WRAP_CONTENT,  LayoutParams.WRAP_CONTENT, true);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top