1

PopupWindow に EditText があります。PopupWindow が表示されると、EditText のカーソルが表示されますが、そのテキストを編集できません。

私のコード:

popupwindolalayout.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>

popupwindow の Java:

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);

私はフラグメントを扱っています。ボタンクリック時にポップアップウィンドウを表示しました。ポップアップ ウィンドウ内に、XML を使用して編集テキストを追加しました。実行中はその編集テキストを入力できませんが、カーソルが表示されて点滅しています。

何か案が?

4

1 に答える 1

3

この行にtrueを追加editnote_popup=new PopupWindow(view, LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);して、フォーカス可能にします。

次のようになります。

editnote_popup=new PopupWindow(view, LayoutParams.WRAP_CONTENT,  LayoutParams.WRAP_CONTENT, true);
于 2014-08-01T19:19:00.627 に答える