本文整理汇总了Java中android.app.Activity.getCurrentFocus方法的典型用法代码示例。如果您正苦于以下问题:Java Activity.getCurrentFocus方法的具体用法?Java Activity.getCurrentFocus怎么用?Java Activity.getCurrentFocus使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.app.Activity
的用法示例。
在下文中一共展示了Activity.getCurrentFocus方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: hideSoftKeyboard
import android.app.Activity; //导入方法依赖的package包/类
public static void hideSoftKeyboard(Activity activity) {
View focusedView = activity.getCurrentFocus();
if (focusedView != null) {
InputMethodManager imm = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(focusedView.getWindowToken(), 0);
}
}
示例2: showKeyboard
import android.app.Activity; //导入方法依赖的package包/类
public static void showKeyboard(Activity activity, boolean isShow) {
InputMethodManager imm = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE);
if (imm == null) throw new NullPointerException("the input Service is null");
View focus = activity.getCurrentFocus();
if (isShow) {
if (focus == null) {
imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);
} else {
imm.showSoftInput(focus, 0);
}
} else {
if (focus != null) {
imm.hideSoftInputFromWindow(focus.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
}
}
}
示例3: hideSoftInput
import android.app.Activity; //导入方法依赖的package包/类
public static boolean hideSoftInput(Activity activity) {
if (activity.getCurrentFocus() != null) {
InputMethodManager imm = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE);
return imm.hideSoftInputFromWindow(activity.getCurrentFocus().getWindowToken(), 0);
}
return false;
}
示例4: hideSoftKeyboard
import android.app.Activity; //导入方法依赖的package包/类
/**
* 隐藏软键盘(只适用于Activity,不适用于Fragment)
*/
public static void hideSoftKeyboard(Activity activity) {
View view = activity.getCurrentFocus();
if (view != null) {
InputMethodManager inputMethodManager = (InputMethodManager) activity.getSystemService(Activity.INPUT_METHOD_SERVICE);
inputMethodManager.hideSoftInputFromWindow(view.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
}
}
示例5: hideSoftkeyboard
import android.app.Activity; //导入方法依赖的package包/类
public static void hideSoftkeyboard(Activity mActivity) {
if (mActivity != null && mActivity.getCurrentFocus() != null) {
InputMethodManager mInputMethodManager = (InputMethodManager) mActivity.getSystemService("input_method");
if (mInputMethodManager != null) {
mInputMethodManager.hideSoftInputFromWindow(mActivity.getCurrentFocus().getWindowToken(), 2);
}
}
}
示例6: hideInputMethod
import android.app.Activity; //导入方法依赖的package包/类
public static void hideInputMethod(Activity mActivity) {
if (mActivity != null && mActivity.getCurrentFocus() != null) {
InputMethodManager mInputMethodManager = (InputMethodManager) mActivity.getSystemService("input_method");
if (mInputMethodManager != null) {
mInputMethodManager.hideSoftInputFromWindow(mActivity.getCurrentFocus().getWindowToken(), 2);
}
}
}
示例7: hideSoftInput
import android.app.Activity; //导入方法依赖的package包/类
/**
* Show Soft Keyboard with new Thread
* @param activity
*/
public static void hideSoftInput(final Activity activity) {
if (activity.getCurrentFocus() != null) {
new Runnable() {
public void run() {
InputMethodManager imm =
(InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(activity.getCurrentFocus().getWindowToken(), 0);
}
}.run();
}
}
示例8: hideInputForce
import android.app.Activity; //导入方法依赖的package包/类
/**
* des:隐藏软键盘,这种方式参数为activity
*
* @param activity
*/
public static void hideInputForce(Activity activity) {
if (activity == null || activity.getCurrentFocus() == null)
return;
((InputMethodManager) activity.getSystemService(INPUT_METHOD_SERVICE))
.hideSoftInputFromWindow(activity.getCurrentFocus()
.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
}
示例9: hideKeyboard
import android.app.Activity; //导入方法依赖的package包/类
public static void hideKeyboard(Activity activity) {
View view = activity.getCurrentFocus();
if (view != null) {
InputMethodManager imm = (InputMethodManager)activity.getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
return;
}
activity.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
}
示例10: hideKeyboard
import android.app.Activity; //导入方法依赖的package包/类
public static void hideKeyboard(@NonNull Activity activity) {
View view = activity.getCurrentFocus();
if (view != null) {
InputMethodManager imm = (InputMethodManager)activity.getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
}
}
示例11: openKeybord
import android.app.Activity; //导入方法依赖的package包/类
public static boolean openKeybord(Activity activity) {
View view = activity.getCurrentFocus();
if (view != null) {
InputMethodManager imm = (InputMethodManager) view.getContext().getSystemService(
Context.INPUT_METHOD_SERVICE);
return imm.showSoftInput(view, InputMethodManager.SHOW_FORCED);
}
return false;
}
示例12: hideSoftKeyboard
import android.app.Activity; //导入方法依赖的package包/类
public static void hideSoftKeyboard(Activity act) {
InputMethodManager inputMethodManager = (InputMethodManager) act.getSystemService(Context.INPUT_METHOD_SERVICE);
if(inputMethodManager != null ) {
View localView = act.getCurrentFocus();
if(localView != null && localView.getWindowToken() != null ) {
IBinder windowToken = localView.getWindowToken();
inputMethodManager.hideSoftInputFromWindow(windowToken, 0);
}
}
}
示例13: showSoftInput
import android.app.Activity; //导入方法依赖的package包/类
public static boolean showSoftInput(Activity activity) {
View view = activity.getCurrentFocus();
if (view != null) {
InputMethodManager imm = (InputMethodManager) view.getContext().getSystemService(
Context.INPUT_METHOD_SERVICE);
return imm.showSoftInput(view, InputMethodManager.SHOW_FORCED);
}
return false;
}
示例14: hideSoftKeyboard
import android.app.Activity; //导入方法依赖的package包/类
public static void hideSoftKeyboard(@Nullable Activity activity) {
if (activity != null) {
View currentFocus = activity.getCurrentFocus();
if (currentFocus != null) {
InputMethodManager inputMethodManager = (InputMethodManager) activity.getSystemService(Activity.INPUT_METHOD_SERVICE);
inputMethodManager.hideSoftInputFromWindow(currentFocus.getWindowToken(), 0);
}
}
}
示例15: hideSoftInput
import android.app.Activity; //导入方法依赖的package包/类
/**
* 关闭键盘
*
* @param activity Activity
*/
public static void hideSoftInput(Activity activity) {
if (activity.getCurrentFocus() != null)
((InputMethodManager) activity
.getSystemService(Context.INPUT_METHOD_SERVICE))
.hideSoftInputFromWindow(activity.getCurrentFocus()
.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
}