使用PopupWindow使EditText可编辑

时间:2019-05-20 07:06:51

标签: java android android-popupwindow

我正在尝试显示PopupWindow

代码如下:

// initialize a pop up window type
PopupWindow popupWindow = new PopupWindow(view, 
    view.getLayoutParams().WRAP_CONTENT,  
    view.getLayoutParams().WRAP_CONTENT, false);

// the drop down list is a list view
RecyclerView listView = new RecyclerView(mContext);
LinearLayoutManager layoutManager = new LinearLayoutManager(mContext);
listView.setLayoutManager(layoutManager);

// set our adapter and pass our pop up window contents

listView.setAdapter(new TaggingAdapter(mContext, users, callback));
// some other visual settings
popupWindow.setFocusable(true);
//view.requestFocus();
popupWindow.setWidth(Utility.dpToPx(mContext.getResources(), 250));
popupWindow.setHeight(Utility.dpToPx(mContext.getResources(), 200));

// set the list view as pop up window content
popupWindow.setContentView(listView);

它确实起作用,但是,它使edittext不可编辑。如果我删除了focus,那么在编辑editText之后,popupWindow就会消失。即使编辑了popupWindow或除非手动将其关闭,如何使edittext保持可用状态。

0 个答案:

没有答案