Possible Duplicate:
PopupWindow not triggering sytem context dialog on EditText long-press
Before I ask this question, I have already spent several hours searching and trying different methods with no luck, it is exactly the same question as this one, which was unanswered, I don't intend to duplicate the question, but I am shocked that this problem is not solved and recorded in SO, cause this requirement is quite common.
This problem is 100% reproducible, simply by creating a PopupWindow with layout that contains an EditText, and long-pressing the EditText, the system edit Dialog does't show up, I know it is a Dialog because of the way it is presented. I am not sure whether it is bug or there are some switches I need to turn on to make EditText work properly in a PopupWindow.
In layout/popupwindow.xml
:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#ffffff" >
<EditText android:id="@+id/etText" android:layout_width="fill_parent" android:layout_height="wrap_content" />
</LinearLayout>
In Activity:
PopupWindow pw = new PopupWindow(getLayoutInflater().inflate(R.layout.popupwindow, null), ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT, true);
pw.setFocusable(true);
pw.setBackgroundDrawable(new BitmapDrawable());
pw.showAtLocation(getWindow().getDecorView(), Gravity.CENTER, 0, 0);
Any ideas?