當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。