评论——回复评论:走同一个编辑框
recycleAdapter.setOnItemClickListener(new recycleAdapter.OnItemClickListener() {
@Override
public void onItemClick(View view, int position) {
isHuifu = true;
SPUtils.saveBoolean("isHuifu",true);
mHuiFuCid = list.get(position).cid;
showSoftInputFromWindow(activity, editContent);
}
});
点击弹出指定EditText的 软键盘
public static void showSoftInputFromWindow(Activity activity, EditText editText) {
editText.requestFocus();
InputMethodManager imn = (InputMethodManager) editText.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
imn.toggleSoftInput(0, InputMethodManager.SHOW_FORCED);
}
由于还要分别是点击回复还是直接评论弹出的,而且可能中间用户收起软键盘,因此要判断
//获取屏幕高度
int screenHeight = this.getWindowManager().getDefaultDisplay().getHeight();
//阀值设置为屏幕高度的1/3
final int keyHeight = screenHeight / 3;
rootView.addOnLayoutChangeListener(new View.OnLayoutChangeListener() {
@Override
public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) {
if (oldBottom != 0 && bottom != 0 && (oldBottom - bottom > keyHeight)) {
LogUtils.e(TAG, "...监听到软键盘弹起..." + isHuifu);
} else if (oldBottom != 0 && bottom != 0 && (bottom - oldBottom > keyHeight)) {
boolean isClick = SPUtils.getBoolean("isHuifu",false);
String strContent = newsDetailWriteComment.getText().toString().trim();
if (isClick){
if (TextUtils.isEmpty(strContent) ) {
isHuifu = false;
SPUtils.saveBoolean("isHuifu", false);
LogUtils.e(TAG, isClick+strContent+"...监听到软件盘关闭..." + isHuifu);
}
}
}
}
});
网友评论