当前位置: 首页>>代码示例>>Java>>正文


Java Activity.getCurrentFocus方法代码示例

本文整理汇总了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);
    }
}
 
开发者ID:PhoenixDevTeam,项目名称:Phoenix-for-VK,代码行数:8,代码来源:ActivityUtils.java

示例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);
        }
    }
}
 
开发者ID:StickyTolt,项目名称:ForeverLibrary,代码行数:17,代码来源:KeyboardUtils.java

示例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;
}
 
开发者ID:wzx54321,项目名称:XinFramework,代码行数:8,代码来源:InputMethodUtils.java

示例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);
    }
}
 
开发者ID:tututututututu,项目名称:BaseCore,代码行数:11,代码来源:KeyboardUtils.java

示例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);
        }
    }
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:9,代码来源:DialogUtil.java

示例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);
        }
    }
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:9,代码来源:UIsUtils.java

示例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();
	}
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:16,代码来源:Utils.java

示例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);
}
 
开发者ID:zybieku,项目名称:SoftKeyboardUtil,代码行数:14,代码来源:KeyBoardUtils.java

示例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);
}
 
开发者ID:JonathandelaSen,项目名称:TheMovies,代码行数:10,代码来源:Utils.java

示例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);
    }
}
 
开发者ID:bignerdranch,项目名称:Typesetter,代码行数:8,代码来源:AndroidUtils.java

示例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;
}
 
开发者ID:TIIEHenry,项目名称:TIIEHenry-Android-SDK,代码行数:10,代码来源:KeyBoardManager.java

示例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);
        }
    }
}
 
开发者ID:Louis19910615,项目名称:youkes_browser,代码行数:11,代码来源:SoftKeyboardUtil.java

示例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;
}
 
开发者ID:jqjm,项目名称:Liteframework,代码行数:10,代码来源:InputMethodUtils.java

示例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);
        }
    }
}
 
开发者ID:aliumujib,项目名称:Orin,代码行数:10,代码来源:Util.java

示例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);
}
 
开发者ID:mangestudio,项目名称:GCSApp,代码行数:13,代码来源:AppUtils.java


注:本文中的android.app.Activity.getCurrentFocus方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。