怎么解决两个PopupWindow时上面一个PopupWindow让输入法框随点空白消失问题

cqhydz 2018-03-14 02:32:50
问题打开了两个PopupWindow 取名 a b , 上面b PopupWindow 上有edittxt 输入时输入弹出输入法将框顶到上面去。现在问题来了,我点b框空白处时,b框消失了,输入法框却并没有消失,除非我再点一下 a空白处,将a消失了,它才能不见。

我做了一下测试,如果我在b框内加个按钮加上事件点 imm.hideSoftInputFromWindow(medit.getWindowToken(), 0); 是可以让输入框消失的,但就是b PopupWindow 点空白消失里没法处理。


a启动就一个空白布局


mPop=new CustomPopupWindow(this);
mPop.setOnItemClickListener(this);
imm = (InputMethodManager) getSystemService(Service.INPUT_METHOD_SERVICE);

findViewById(R.id.id_start).setOnClickListener(new View.OnClickListener() {

@Override
public void onClick(View v) {


//设置PopupWindow中的位置
mPop.showAtLocation(PopupWin.this.findViewById(R.id.main), Gravity.BOTTOM|Gravity.CENTER_HORIZONTAL, 0,0);
}
});



b启动
View layout;
private void writeDelivery() {
layout = getLayoutInflater().inflate(R.layout.playvideo_popsned,null);

EditText inputCmpny = (EditText) layout.findViewById(R.id.movpopwin_edit);

int H;
H = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED);
layout.measure(0, H);
H = layout.getMeasuredHeight();

// pop = new PopupWindow(layout, DeviceUtil.getScreenPixels(this).getWidth(), H);
pop = new PopupWindow(layout, ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.WRAP_CONTENT,true);

ColorDrawable cd = new ColorDrawable(-0000);
pop.setBackgroundDrawable(cd);


pop.update();
pop.setInputMethodMode(PopupWindow.INPUT_METHOD_NEEDED);
pop.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
pop.setTouchable(true); // 设置popupwindow可点击
pop.setOutsideTouchable(true); // 设置popupwindow外部可点击
pop.setFocusable(true); // 获取焦点
pop.showAtLocation(layout, Gravity.BOTTOM, 0, 0);


pop.setTouchInterceptor(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
/**** 如果点击了popupwindow的外部,popupwindow也会消失 ****/
if (event.getAction() == MotionEvent.ACTION_OUTSIDE) {
EditText movpoedit = (EditText) layout.findViewById(R.id.win_edit);

imm.hideSoftInputFromWindow(movpoedit.getWindowToken(), 0);
pop.dismiss();
return true;
}
return false;
}

});

}


b布局
 
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ffffff" >


<LinearLayout
android:id="@+id/layout_message"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="2px" >

<EditText
android:id="@+id/win_edit"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginLeft="16dp"
android:textColor="#7f8c8d"
android:layout_weight="1"
android:background="#ffffff"
android:hint=" 评论"
android:textSize="15sp"
android:singleLine="true" />


</LinearLayout>
</FrameLayout>
...全文
402 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
zhang106209 2018-03-14
  • 打赏
  • 举报
回复
你判断b布局是否消失,消失就隐藏软键盘

80,351

社区成员

发帖
与我相关
我的任务
社区描述
移动平台 Android
androidandroid-studioandroidx 技术论坛(原bbs)
社区管理员
  • Android
  • yechaoa
  • 失落夏天
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧