
評論——回復(fù)評論:走同一個編輯框
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);
}
由于還要分別是點擊回復(fù)還是直接評論彈出的,而且可能中間用戶收起軟鍵盤,因此要判斷
//獲取屏幕高度
int screenHeight = this.getWindowManager().getDefaultDisplay().getHeight();
//閥值設(shè)置為屏幕高度的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, "...監(jiān)聽到軟鍵盤彈起..." + 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+"...監(jiān)聽到軟件盤關(guān)閉..." + isHuifu);
}
}
}
}
});