本文整理汇总了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);
}
}
示例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);
}
}
}
}
示例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);
}
示例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);
}
}
}
}
}
}
示例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);
}
示例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);
}
示例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);
}
}
}
示例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);
}
}
示例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);
}
}
}
}
示例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;
}
示例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;
}
示例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);
}
}
}
示例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);
}
}
}
示例14: isAttachedToWindow
import android.view.View; //导入方法依赖的package包/类
static boolean isAttachedToWindow(View view) {
return view.getWindowToken() != null;
}