popupwindow弹出的editTextView
2017-07-13 18:59
441 查看
public void getCommentView(final Activity context, View view, final CommentResult commentResult) { liveCommentResult = commentResult; if (commentView == null) { commentView = context.getLayoutInflater().inflate(R.layout.comment_question, null); } if (commentPopup == null) { // 创建一个PopuWidow对象 commentPopup = new PopupWindow(commentView, LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT); } // 设置动画 commentPopup.setAnimationStyle(R.style.popWindow_animation_in2out); // 使其聚集 ,要想监听菜单里控件的事件就必须要调用此方法 commentPopup.setFocusable(true); // 设置允许在外点击消失 commentPopup.setOutsideTouchable(true); // 设置背景,这个是为了点击“返回Back”也能使其消失,并且并不会影响你的背景 commentPopup.setBackgroundDrawable(new BitmapDrawable()); //必须加这两行,不然不会显示在键盘上方 commentPopup.setSoftInputMode(PopupWindow.INPUT_METHOD_NEEDED); commentPopup.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE); // PopupWindow的显示及位置设置 commentPopup.showAtLocation(view, Gravity.BOTTOM, 0, 0); comment_text = (EditText) commentView.findViewById(R.id.comment_text); TextView send_comment = (TextView) commentView.findViewById(R.id.send_comment); comment_text.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { } @Override public void afterTextChanged(Editable s) { if (s.length() > 0) { send_comment.setSelected(true); send_comment.setEnabled(true); } else { send_comment.setSelected(false); send_comment.setEnabled(false); } } }); //这是布局中发送按钮的监听 send_comment.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { String comment = comment_text.getText().toString(); if (!TextUtils.isEmpty(comment)) { if (TextUtils.isEmpty(comment.trim())) { send_comment.setEnabled(false); } else { send_comment.setEnabled(true); //把数据传出去 liveCommentResult.onResult(true, comment); //关闭popup commentPopup.dismiss(); } Toast.makeText(getContext(), getResources().getString(R.string.comment_is_none), Toast.LENGTH_SHORT).show(); } } }); //设置popup关闭时要做的操作 commentPopup.setOnDismissListener(new PopupWindow.OnDismissListener() { @Override public void onDismiss() { hideKeyboard(comment_text); comment_text.setText(""); } }); //显示软键盘 Timer timer = new Timer(); timer.schedule(new TimerTask() { @Override public void run() { //此方法就不提供了,网上一大推 showSoftKeyboard(); } }, 200); //显示键盘 } /** * 发送评论回调 */ public interface CommentResult { void onResult(boolean confirmed, String comment); }
相关文章推荐
- 关于popupwindow中含有EditText,点击无法弹出键盘的问题
- 安卓中PopupWindow中的EditText无法弹出软键盘解决
- android 点击EditTextView不弹出输入法
- android点击popupwindow里edittext崩溃的解决办法
- ListView里面有EditText,弹出键盘后EditView立刻不能获取焦点的问题
- 解决RecyclerView实现聊天界面,但点击下面的EditText后弹出的输入法会遮盖RecyclerView内容的方法
- 圆角PopupWindow对话框和圆角EditText
- ListView里面有EditTextView,解决弹出键盘后EditView不能获取焦点的问题
- 仿微信 QQ聊天布局 顶部title固定,底部是EditText,中间是RecyclerView,弹出软键盘,RecyclerView上移,标题不动
- EditText或者TextView单击时弹出DatePicker对话框,然后弹出软键盘,后来我禁止EditText还是弹出来
- android自定义spinner,使用AppCompatTextView+PopupWindow 实现下拉选择的功能
- android 点击EditTextView不弹出输入法
- Android 笔记 ---- PopupWindow中有EditText,EditText被输入法盖住
- android 带EditText的popwindow 当弹出输入法后popwindow被输入法覆盖掉的解决方法。
- Android开发之旅一PopupWindow写的一个基类和PopupWindow中EditText输入法的问题
- popupWindow+软键盘弹出,edittext设置,textview字体颜色设置,log打印过长显示不出来的问题
- ListView里面有EditTextView,解决弹出键盘后EditView不能获取焦点的问题
- PopupWindow中EditText无法长按出现selection markers
- 关于ScrollView中一个EditTextView弹出软键盘不上顶
- TextView长按自由选择复制,弹出popwindow菜单,划线,删除线,做笔记