android.widget.PopupWindow#setInputMethodMode ( )源码实例Demo

下面列出了android.widget.PopupWindow#setInputMethodMode ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: AndroidWallet   文件: DropPopMenu.java
@SuppressLint("ClickableViewAccessibility")
private void create() {
    mPopupWindow = new PopupWindow(mDropPopLayout, LinearLayout.LayoutParams.MATCH_PARENT
            , LinearLayout.LayoutParams.WRAP_CONTENT);
    mPopupWindow.setInputMethodMode(PopupWindow.INPUT_METHOD_NEEDED);
    mPopupWindow.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
    mPopupWindow.setFocusable(true);
    mPopupWindow.setBackgroundDrawable(new BitmapDrawable());
    mPopupWindow.setOnDismissListener(new PopOnDismissListener());

    mDropPopLayout.setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View view, MotionEvent motionEvent) {
            mPopupWindow.dismiss();
            return true;
        }
    });
}
 
源代码2 项目: YCDialog   文件: CustomPopupWindow.java
private void apply(PopupWindow mPopupWindow) {
    mPopupWindow.setClippingEnabled(this.mClippEnable);
    if(this.mIgnoreCheekPress) {
        mPopupWindow.setIgnoreCheekPress();
    }

    if(this.mInputMode != -1) {
        mPopupWindow.setInputMethodMode(this.mInputMode);
    }

    if(this.mSoftInputMode != -1) {
        mPopupWindow.setSoftInputMode(this.mSoftInputMode);
    }

    if(this.mOnDismissListener != null) {
        mPopupWindow.setOnDismissListener(this.mOnDismissListener);
    }

    if(this.mOnTouchListener != null) {
        mPopupWindow.setTouchInterceptor(this.mOnTouchListener);
    }

    mPopupWindow.setTouchable(this.mTouchable);
}
 
源代码3 项目: ImmersionBar   文件: PopupActivity.java
/**
 * 弹出popupWindow
 * Show popup.
 *
 * @param gravity        the gravity
 * @param width          the width
 * @param height         the height
 * @param animationStyle the animation style
 */
private void showPopup(int gravity, int width, int height, int animationStyle) {
    mPopupView = LayoutInflater.from(mActivity).inflate(R.layout.popup_demo, null);
    mPopupWindow = new PopupWindow(mPopupView, width, height);
    //以下属性响应空白处消失和实体按键返回消失popup
    mPopupWindow.setOutsideTouchable(true);
    mPopupWindow.setFocusable(true);
    mPopupWindow.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
    //沉浸式模式下,以下两个属性并不起作用
    mPopupWindow.setInputMethodMode(PopupWindow.INPUT_METHOD_NEEDED);
    mPopupWindow.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
    //重点,此方法可以让布局延伸到状态栏和导航栏
    mPopupWindow.setClippingEnabled(false);
    //设置动画
    mPopupWindow.setAnimationStyle(animationStyle);
    //弹出
    mPopupWindow.showAtLocation(getWindow().getDecorView(), gravity, 0, 0);
    //弹出后背景alpha值
    backgroundAlpha(0.5f);
    //消失后恢复背景alpha值
    mPopupWindow.setOnDismissListener(() -> backgroundAlpha(1f));
    //适配弹出popup后布局被状态栏和导航栏遮挡问题
    updatePopupView();
}
 
源代码4 项目: Emoji   文件: EmojiVariantPopup.java
public void show(@NonNull final EmojiImageView clickedImage, @NonNull final Emoji emoji) {
  dismiss();

  rootImageView = clickedImage;

  final View content = initView(clickedImage.getContext(), emoji, clickedImage.getWidth());

  popupWindow = new PopupWindow(content, WindowManager.LayoutParams.WRAP_CONTENT, WindowManager.LayoutParams.WRAP_CONTENT);
  popupWindow.setFocusable(true);
  popupWindow.setOutsideTouchable(true);
  popupWindow.setInputMethodMode(PopupWindow.INPUT_METHOD_NOT_NEEDED);
  popupWindow.setBackgroundDrawable(new BitmapDrawable(clickedImage.getContext().getResources(), (Bitmap) null));

  content.measure(makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED), makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED));

  final Point location = Utils.locationOnScreen(clickedImage);
  final Point desiredLocation = new Point(
          location.x - content.getMeasuredWidth() / 2 + clickedImage.getWidth() / 2,
          location.y - content.getMeasuredHeight()
  );

  popupWindow.showAtLocation(rootView, Gravity.NO_GRAVITY, desiredLocation.x, desiredLocation.y);
  rootImageView.getParent().requestDisallowInterceptTouchEvent(true);
  Utils.fixPopupLocation(popupWindow, desiredLocation);
}
 
源代码5 项目: Emoji   文件: EmojiPopup.java
EmojiPopup(@NonNull final EmojiPopup.Builder builder, @NonNull final EditText editText) {
  this.context = Utils.asActivity(builder.rootView.getContext());
  this.rootView = builder.rootView.getRootView();
  this.editText = editText;
  this.recentEmoji = builder.recentEmoji;
  this.variantEmoji = builder.variantEmoji;

  popupWindow = new PopupWindow(context);
  variantPopup = new EmojiVariantPopup(rootView, internalOnEmojiClickListener);

  final EmojiView emojiView = new EmojiView(context,
          internalOnEmojiClickListener, internalOnEmojiLongClickListener, builder);

  emojiView.setOnEmojiBackspaceClickListener(internalOnEmojiBackspaceClickListener);

  popupWindow.setContentView(emojiView);
  popupWindow.setInputMethodMode(PopupWindow.INPUT_METHOD_NOT_NEEDED);
  popupWindow.setBackgroundDrawable(new BitmapDrawable(context.getResources(), (Bitmap) null)); // To avoid borders and overdraw.
  popupWindow.setOnDismissListener(onDismissListener);

  if (builder.keyboardAnimationStyle != 0) {
    popupWindow.setAnimationStyle(builder.keyboardAnimationStyle);
  }

  rootView.addOnAttachStateChangeListener(onAttachStateChangeListener);
}
 
源代码6 项目: LLApp   文件: CustomPopWindow.java
/**
 * 添加一些属性设置
 * @param popupWindow
 */
private void apply(PopupWindow popupWindow){
    popupWindow.setClippingEnabled(mClippEnable);
    if(mIgnoreCheekPress){
        popupWindow.setIgnoreCheekPress();
    }
    if(mInputMode!=-1){
        popupWindow.setInputMethodMode(mInputMode);
    }
    if(mSoftInputMode!=-1){
        popupWindow.setSoftInputMode(mSoftInputMode);
    }
    if(mOnDismissListener!=null){
        popupWindow.setOnDismissListener(mOnDismissListener);
    }
    if(mOnTouchListener!=null){
        popupWindow.setTouchInterceptor(mOnTouchListener);
    }
    popupWindow.setTouchable(mTouchable);



}
 
源代码7 项目: Autocomplete   文件: AutocompletePopup.java
/**
 * Create a new, empty popup window capable of displaying items from a ListAdapter.
 * Backgrounds should be set using {@link #setBackgroundDrawable(Drawable)}.
 *
 * @param context Context used for contained views.
 */
AutocompletePopup(@NonNull Context context) {
    super();
    mContext = context;
    mPopup = new PopupWindow(context);
    mPopup.setInputMethodMode(PopupWindow.INPUT_METHOD_NEEDED);
}
 
private void init() {
    mCommandAdapter = new CommandListSuggestionsAdapter(getContext());
    mCommandAdapter.setClickListener(this);
    List<CommandAliasManager.CommandAlias> additionalItems = new ArrayList<>();
    additionalItems.add(CommandAliasManager.CommandAlias.raw("wait", "<seconds>", ""));
    additionalItems.add(CommandAliasManager.CommandAlias.raw("wait-for", "<channel>", ""));
    mCommandAdapter.setAdditionalItems(additionalItems);

    mSuggestionsList = new RecyclerView(getContext());
    mSuggestionsList.setAdapter(mCommandAdapter);
    mSuggestionsList.setLayoutManager(new LinearLayoutManager(getContext()));

    mPopupAnchor = new View(getContext());

    mPopupWindow = new PopupWindow(getContext(), null, android.R.attr.listPopupWindowStyle);
    mPopupWindow.setContentView(mSuggestionsList);
    mPopupWindow.setWidth(ViewGroup.LayoutParams.WRAP_CONTENT);
    mPopupWindow.setInputMethodMode(PopupWindow.INPUT_METHOD_NEEDED);

    mPopupItemHeight = StyledAttributesHelper.getDimensionPixelSize(getContext(),
            android.R.attr.listPreferredItemHeightSmall, 0);
    mMaxPopupHeight = getResources().getDimensionPixelSize(R.dimen.list_popup_max_height);

    addTextChangedListener(new SimpleTextWatcher((Editable s) -> {
        if (enoughToFilter())
            performFiltering(false);
        else
            dismissDropDown();
    }));
}
 
源代码9 项目: mobile-manager-tool   文件: SearchResultPop.java
public SearchResultPop(Context context, final FileListAdapter adapter){

        this.adapter = adapter;

        WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);

        LayoutInflater layoutInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        View view = layoutInflater.inflate(R.layout.search_result_pop, null);

        GridView gridView = (GridView) view.findViewById(R.id.gridView);
        gridView.setAdapter(adapter);
        gridView.requestFocus();
        // EditText 与 popwindow焦点冲突
//        gridView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
//            public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
//                popupWindow.setFocusable(true);
//                listener.onClick((FileInfo)adapter.getItem(arg2), arg2);
//            }
//        });

        popupWindow = new PopupWindow(view,
                windowManager.getDefaultDisplay().getWidth(),
                windowManager.getDefaultDisplay().getHeight()*4/5);

        // 使其聚集
        //popupWindow.setFocusable(true);
        // 解决popupWindow挡住虚拟键盘
        popupWindow.setInputMethodMode(PopupWindow.INPUT_METHOD_NEEDED);
        popupWindow.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
        // 设置允许在外点击消失
        popupWindow.setOutsideTouchable(false);
        // 这个是为了点击“返回Back”也能使其消失,并且并不会影响你的背景
        popupWindow.setBackgroundDrawable(new BitmapDrawable());
    }
 
源代码10 项目: SSForms   文件: StarkSpinner.java
private void init() {
    setupColors();
    setupList();
    mSearchEditText.setImeOptions(EditorInfo.IME_ACTION_DONE | EditorInfo.IME_FLAG_NO_EXTRACT_UI);
    mStartSearchImageView.setOnClickListener(this);
    mDoneSearchImageView.setOnClickListener(this);
    mSearchEditText.addTextChangedListener(mTextWatcher);

    mPopupWindow = new PopupWindow(mContext);
    mPopupWindow.setContentView(mSpinnerListContainer);
    mPopupWindow.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
    mPopupWindow.setInputMethodMode(PopupWindow.INPUT_METHOD_NEEDED);
    mPopupWindow.setOnDismissListener(new PopupWindow.OnDismissListener() {
        @Override
        public void onDismiss() {
            hideEdit();
        }
    });
    mPopupWindow.setFocusable(false);
    mPopupWindow.setElevation(DefaultElevation);
    mPopupWindow.setBackgroundDrawable(ContextCompat.getDrawable(mContext, R.drawable.spinner_drawable));

    mSpinnerListView.setOnItemClickListener(mOnItemSelectedListener);
    if (mCurrSelectedView == null) {
        if (!TextUtils.isEmpty(mSearchHintText)) {
            mSearchEditText.setHint(mSearchHintText);
        }
        if (!TextUtils.isEmpty(mNoItemsFoundText)) {
            mEmptyTextView.setText(mNoItemsFoundText);
        }
        if (mCurrSelectedView == null && !TextUtils.isEmpty(mRevealEmptyText)) {
            TextView textView = new TextView(mContext);
            textView.setText(mRevealEmptyText);
            mCurrSelectedView = new SelectedView(textView, -1, 0);
            mRevealItem.addView(textView);
        }
    } else {
        mSpinnerListView.performItemClick(mCurrSelectedView.getView(), mCurrSelectedView.getPosition(), mCurrSelectedView.getId());
    }
    clearAnimation();
    clearFocus();
}
 
源代码11 项目: searchablespinner   文件: SearchableSpinner.java
private void init() {
    setupColors();
    setupList();
    mSearchEditText.setImeOptions(EditorInfo.IME_ACTION_DONE | EditorInfo.IME_FLAG_NO_EXTRACT_UI);
    mStartSearchImageView.setOnClickListener(this);
    mDoneSearchImageView.setOnClickListener(this);
    mSearchEditText.addTextChangedListener(mTextWatcher);

    mPopupWindow = new PopupWindow(mContext);
    mPopupWindow.setContentView(mSpinnerListContainer);
    mPopupWindow.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
    mPopupWindow.setInputMethodMode(PopupWindow.INPUT_METHOD_NEEDED);
    mPopupWindow.setOnDismissListener(new PopupWindow.OnDismissListener() {
        @Override
        public void onDismiss() {
            hideEdit();
        }
    });
    mPopupWindow.setFocusable(false);
    mPopupWindow.setElevation(DefaultElevation);
    mPopupWindow.setBackgroundDrawable(ContextCompat.getDrawable(mContext, R.drawable.spinner_drawable));

    mSpinnerListView.setOnItemClickListener(mOnItemSelectedListener);
    if (mCurrSelectedView == null) {
        if (!TextUtils.isEmpty(mSearchHintText)) {
            mSearchEditText.setHint(mSearchHintText);
        }
        if (!TextUtils.isEmpty(mNoItemsFoundText)) {
            mEmptyTextView.setText(mNoItemsFoundText);
        }
        if (mCurrSelectedView == null && !TextUtils.isEmpty(mRevealEmptyText)) {
            TextView textView = new TextView(mContext);
            textView.setText(mRevealEmptyText);
            mCurrSelectedView = new SelectedView(textView, -1, 0);
            mRevealItem.addView(textView);
        }
    } else {
        mSpinnerListView.performItemClick(mCurrSelectedView.getView(), mCurrSelectedView.getPosition(), mCurrSelectedView.getId());
    }
    clearAnimation();
    clearFocus();
}
 
源代码12 项目: android-apps   文件: IcsListPopupWindow.java
public IcsListPopupWindow(Context context, AttributeSet attrs, int defStyleAttr) {
    mContext = context;
    mPopup = new PopupWindow(context, attrs, defStyleAttr);
    mPopup.setInputMethodMode(PopupWindow.INPUT_METHOD_NEEDED);
}