當前位置: 首頁>>代碼示例>>Java>>正文


Java View.getWindowToken方法代碼示例

本文整理匯總了Java中android.view.View.getWindowToken方法的典型用法代碼示例。如果您正苦於以下問題:Java View.getWindowToken方法的具體用法?Java View.getWindowToken怎麽用?Java View.getWindowToken使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.view.View的用法示例。


在下文中一共展示了View.getWindowToken方法的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: closeKeyBoard

import android.view.View; //導入方法依賴的package包/類
protected void closeKeyBoard() throws NullPointerException {
    // Central system API to the overall input method framework (IMF) architecture
    InputMethodManager inputManager =
            (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);

    View currentFocus = getCurrentFocus();
    if (currentFocus != null) {
        // Base interface for a remotable object
        IBinder windowToken = currentFocus.getWindowToken();

        // Hide type
        int hideType = InputMethodManager.HIDE_NOT_ALWAYS;

        // Hide the KeyBoard
        inputManager.hideSoftInputFromWindow(windowToken, hideType);
    }
}
 
開發者ID:tranleduy2000,項目名稱:javaide,代碼行數:18,代碼來源:ProjectManagerActivity.java

示例2: registerListener

import android.view.View; //導入方法依賴的package包/類
private void registerListener(View anchor) {
    // Don't do anything if we haven't managed to patch the super listener.
    // And don't bother attaching the listener if the anchor view isn't
    // attached. This means we'll only have to deal with the real VTO owned
    // by the ViewRoot.
    if (mSuperScrollListener != null) {
        ViewTreeObserver vto = (anchor.getWindowToken() != null) ? anchor.getViewTreeObserver()
                : null;
        if (vto != mViewTreeObserver) {
            if (mViewTreeObserver != null && mViewTreeObserver.isAlive()) {
                mViewTreeObserver.removeOnScrollChangedListener(mSuperScrollListener);
            }
            if ((mViewTreeObserver = vto) != null) {
                vto.addOnScrollChangedListener(mSuperScrollListener);
            }
        }
    }
}
 
開發者ID:treasure-lau,項目名稱:CSipSimple,代碼行數:19,代碼來源:PopupWindowCompat.java

示例3: show

import android.view.View; //導入方法依賴的package包/類
private void show(View view, int left, int top) {
    if (view.getParent() != null || view.getWindowToken() != null) {
        windowManager.removeView(view);
    }
    WindowManager.LayoutParams params = new WindowManager.LayoutParams(
            WindowManager.LayoutParams.WRAP_CONTENT,
            WindowManager.LayoutParams.WRAP_CONTENT,
            WindowManager.LayoutParams.TYPE_PHONE,
            WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
                    | WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL
                    | WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH
                    | WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS,
            PixelFormat.TRANSLUCENT);
    params.gravity = Gravity.START | Gravity.TOP;
    params.x = left;
    params.y = top;
    windowManager.addView(view, params);
}
 
開發者ID:RajneeshSingh007,項目名稱:MusicX-music-player,代碼行數:19,代碼來源:AudioWidget.java

示例4: closeInputKeyboard

import android.view.View; //導入方法依賴的package包/類
/**
 * 關閉軟鍵盤
 * @param activity
 */
public static void closeInputKeyboard(Activity activity) {
    if(activity != null) {
        InputMethodManager inputMethodManager = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE);
        if(inputMethodManager != null) {
            boolean active = inputMethodManager.isActive();
            if (active) {
                View currentFocus = activity.getCurrentFocus();
                if (currentFocus != null) {
                    IBinder windowToken = currentFocus.getWindowToken();
                    if (windowToken != null) {
                        inputMethodManager.hideSoftInputFromWindow(
                                windowToken,
                                InputMethodManager.HIDE_NOT_ALWAYS);
                    }
                }
            }
        }
    }
}
 
開發者ID:Sugarya,項目名稱:FragmentCapsulation,代碼行數:24,代碼來源:KeyboardUtils.java

示例5: hideSoftKeyboard

import android.view.View; //導入方法依賴的package包/類
public static void hideSoftKeyboard(Activity activity) {
    InputMethodManager inputMethodManager =
            (InputMethodManager) activity.getSystemService(
                    Activity.INPUT_METHOD_SERVICE);
    View focusedView = activity.getCurrentFocus();
    if(focusedView == null)
        return;
    IBinder token = focusedView.getWindowToken();
    if(token != null)
        inputMethodManager.hideSoftInputFromWindow(token, 0);
}
 
開發者ID:Bruno125,項目名稱:Unofficial-Ups,代碼行數:12,代碼來源:UiUtils.java

示例6: closeSoftKeyboard

import android.view.View; //導入方法依賴的package包/類
/**
 * 關閉軟鍵盤
 * 當使用全屏主題的時候,XhsEmoticonsKeyBoard屏蔽了焦點.關閉軟鍵盤時,直接指定 closeSoftKeyboard(EditView)
 * @param view
 */
public static void closeSoftKeyboard(View view) {
    if (view == null || view.getWindowToken() == null) {
        return;
    }
    InputMethodManager imm = (InputMethodManager) view.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
    imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:13,代碼來源:EmoticonsKeyboardUtils.java

示例7: hideKeyboard

import android.view.View; //導入方法依賴的package包/類
public static void hideKeyboard(@NonNull final DialogInterface di,
                                @NonNull final MaterialDialog.Builder builder) {
    final MaterialDialog dialog = (MaterialDialog) di;
    if (dialog.getInputEditText() == null) return;
    InputMethodManager imm = (InputMethodManager) builder.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
    if (imm != null) {
        final View currentFocus = dialog.getCurrentFocus();
        final IBinder windowToken = currentFocus != null ?
                currentFocus.getWindowToken() : dialog.getView().getWindowToken();
        if (windowToken != null) {
            imm.hideSoftInputFromWindow(windowToken, 0);
        }
    }
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:15,代碼來源:DialogUtils.java

示例8: closeKeyboard

import android.view.View; //導入方法依賴的package包/類
public static void closeKeyboard(Activity activity) {

        final View v = activity.getWindow().peekDecorView();
        if (v != null && v.getWindowToken() != null) {
            InputMethodManager imm = (InputMethodManager) activity.getSystemService(
                    INPUT_METHOD_SERVICE);
            imm.hideSoftInputFromWindow(v.getWindowToken(), 0);
        }
    }
 
開發者ID:enricocid,項目名稱:LaunchEnr,代碼行數:10,代碼來源:Launcher.java

示例9: registerListener

import android.view.View; //導入方法依賴的package包/類
private void registerListener(View anchor) {
    if (mSuperScrollListener != null) {
        ViewTreeObserver vto = (anchor.getWindowToken() != null) ? anchor.getViewTreeObserver() : null;
        if (vto != mViewTreeObserver) {
            if (mViewTreeObserver != null && mViewTreeObserver.isAlive()) {
                mViewTreeObserver.removeOnScrollChangedListener(mSuperScrollListener);
            }
            if ((mViewTreeObserver = vto) != null) {
                vto.addOnScrollChangedListener(mSuperScrollListener);
            }
        }
    }
}
 
開發者ID:pooyafaroka,項目名稱:PlusGram,代碼行數:14,代碼來源:EmojiView.java

示例10: tryShow

import android.view.View; //導入方法依賴的package包/類
public boolean tryShow() {
    mPopup = new IcsListPopupWindow(mContext, null, R.attr.popupMenuStyle);
    mPopup.setOnDismissListener(this);
    mPopup.setOnItemClickListener(this);

    mAdapter = new MenuAdapter(mMenu);
    mPopup.setAdapter(mAdapter);
    mPopup.setModal(true);

    View anchor = mAnchorView;
    if (anchor != null) {
        // Don't attach to the VTO unless the anchor itself is attached to avoid VTO-related leaks.
        if (anchor.getWindowToken() != null) {
            ViewTreeObserver vto = anchor.getViewTreeObserver();
            if (vto != mTreeObserver) {
                if (mTreeObserver != null && mTreeObserver.isAlive()) {
                    mTreeObserver.removeGlobalOnLayoutListener(this);
                }
                if ((mTreeObserver = vto) != null) {
                    vto.addOnGlobalLayoutListener(this);
                }
            }
        } else if (anchor instanceof View_HasStateListenerSupport) {
            ((View_HasStateListenerSupport) anchor).addOnAttachStateChangeListener(this);
        }
        mPopup.setAnchorView(anchor);
    } else {
        return false;
    }

    mPopup.setContentWidth(Math.min(measureContentWidth(mAdapter), mPopupMaxWidth));
    mPopup.setInputMethodMode(PopupWindow.INPUT_METHOD_NOT_NEEDED);
    mPopup.show();
    mPopup.getListView().setOnKeyListener(this);
    return true;
}
 
開發者ID:treasure-lau,項目名稱:CSipSimple,代碼行數:37,代碼來源:MenuPopupHelper.java

示例11: setSizeOfUnattachedView

import android.view.View; //導入方法依賴的package包/類
/**
 * Resize {@code view} to match the size of this {@link FrameLayout}.  This will only happen if
 * {@code view} is not {@code null} and if {@link View#getWindowToken()} returns {@code null}
 * (the {@link View} is not part of the view hierarchy).
 * @param view The {@link View} to resize.
 * @return     Whether or not {@code view} was resized.
 */
private boolean setSizeOfUnattachedView(View view) {
    // Need to call layout() for the following View if it is not attached to the view hierarchy.
    // Calling onSizeChanged() is dangerous because if the View has a different size than the
    // ContentViewCore it might think a future size update is a NOOP and not call
    // onSizeChanged() on the ContentViewCore.
    if (view == null || view.getWindowToken() != null) return false;
    int width = getWidth();
    int height = getHeight();
    view.measure(MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY),
            MeasureSpec.makeMeasureSpec(height, MeasureSpec.EXACTLY));
    view.layout(0, 0, view.getMeasuredWidth(), view.getMeasuredHeight());
    return true;
}
 
開發者ID:rkshuai,項目名稱:chromium-for-android-56-debug-video,代碼行數:21,代碼來源:CompositorViewHolder.java

示例12: hideSoftKeyboard

import android.view.View; //導入方法依賴的package包/類
/**
 * hide inputMethod
 */
public void hideSoftKeyboard() {
    InputMethodManager inputMethodManager = (InputMethodManager) mActionBarActivity.getSystemService(Context.INPUT_METHOD_SERVICE);
    if(inputMethodManager != null ) {
        View localView = mActionBarActivity.getCurrentFocus();
        if(localView != null && localView.getWindowToken() != null ) {
            IBinder windowToken = localView.getWindowToken();
            inputMethodManager.hideSoftInputFromWindow(windowToken, 0);
        }
    }
}
 
開發者ID:Louis19910615,項目名稱:youkes_browser,代碼行數:14,代碼來源:CCPActivityBase.java

示例13: displaySoftKeyboard

import android.view.View; //導入方法依賴的package包/類
/**
 *
 */
public void displaySoftKeyboard() {
    final FragmentActivity activity = mActionBarActivity;
    // Display the soft keyboard
    InputMethodManager inputMethodManager = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE);
    if (inputMethodManager != null) {
        View localView = activity.getCurrentFocus();
        if (localView != null && localView.getWindowToken() != null) {
            inputMethodManager.toggleSoftInput(0,InputMethodManager.HIDE_NOT_ALWAYS);
        }
    }
}
 
開發者ID:NewCasino,項目名稱:browser,代碼行數:15,代碼來源:CCPActivityBase.java

示例14: isAttachedToWindow

import android.view.View; //導入方法依賴的package包/類
static boolean isAttachedToWindow(View view) {
    return view.getWindowToken() != null;
}
 
開發者ID:JackChan1999,項目名稱:letv,代碼行數:4,代碼來源:ViewCompatBase.java


注:本文中的android.view.View.getWindowToken方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。