当前位置: 首页>>代码示例>>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;未经允许,请勿转载。