以下总结了几个在工作中经常会被用到的工具类
状态栏相关方法
/**
* 显示状态栏
*/
private void showStatusBar() {
int flag = WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN;
Window window = this.getWindow();
window.setFlags(flag, flag);
}
/**
* 隐藏状态栏
*/
private void hideStatusBar() {
int flag = WindowManager.LayoutParams.FLAG_FULLSCREEN;
Window window = this.getWindow();
window.setFlags(flag, flag);
}
软键盘相关方法
/** 显示和隐藏软键盘 View : EditText、TextView isShow : true = show , false = hide
* @param context
* @param view
* @param isShow
*/
public static void popSoftKeyboard(Context context, View view,boolean isShow) {
InputMethodManager imm = (InputMethodManager context.getSystemService(Context.INPUT_METHOD_SERVICE);
if (isShow) {
view.requestFocus();
imm.showSoftInput(view, InputMethodManager.SHOW_IMPLICIT);
} else {
imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
}
}
/**
* 显示软键盘
*
* @param view
*/
public static void showSoftKeyboard(View view) {
Context context = view.getContext();
InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
view.requestFocus();
imm.showSoftInput(view, InputMethodManager.SHOW_IMPLICIT);
}
/**
* 隐藏软键盘
*
* @param view
*/
public static void hideSoftKeyboard(View view) {
Context context = view.getContext();
InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
}
不定时更新中…