本文整理匯總了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);
}