Java Code Examples for android.widget.ListPopupWindow#setPromptPosition()
The following examples show how to use
android.widget.ListPopupWindow#setPromptPosition() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: EditSpinner.java From EditSpinner with Apache License 2.0 | 5 votes |
private void initPopupWindow() { popupWindow = new ListPopupWindow(mContext) { @Override public void show() { super.show(); mRightImageTopView.setClickable(true); mRightIv.startAnimation(mAnimation); } @Override public void dismiss() { super.dismiss(); } }; popupWindow.setOnItemClickListener(this); popupWindow.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE); popupWindow.setPromptPosition(ListPopupWindow.POSITION_PROMPT_BELOW); popupWindow.setWidth(ViewGroup.LayoutParams.WRAP_CONTENT); popupWindow.setHeight(ViewGroup.LayoutParams.WRAP_CONTENT); popupWindow.setAnchorView(editText); popupWindow.setOnDismissListener(new PopupWindow.OnDismissListener() { @Override public void onDismiss() { popupWindowHideTime = System.currentTimeMillis(); mRightIv.startAnimation(mResetAnimation); } }); }
Example 2
Source File: EditSpinner.java From Edit-Spinner with Apache License 2.0 | 4 votes |
private void initFromAttributes(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { final TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.EditSpinner, defStyleAttr, defStyleRes); mPopup = new ListPopupWindow(context, attrs); mPopup.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE); mPopup.setPromptPosition(ListPopupWindow.POSITION_PROMPT_BELOW); Drawable selector = a.getDrawable(R.styleable.EditSpinner_dropDownSelector); if (selector != null) { mPopup.setListSelector(selector); } int dropDownAnimStyleResId = a.getResourceId(R.styleable.EditSpinner_dropDownAnimStyle, -1); if (dropDownAnimStyleResId > 0) { setDropDownAnimationStyle(dropDownAnimStyleResId); } mDropDownDrawable = a.getDrawable(R.styleable.EditSpinner_dropDownDrawable); int dropDownDrawableSpacing = a.getDimensionPixelOffset(R.styleable.EditSpinner_dropDownDrawableSpacing, 0); if (mDropDownDrawable != null) { int dropDownDrawableWidth = a.getDimensionPixelOffset(R.styleable.EditSpinner_dropDownDrawableWidth, -1); int dropDownDrawableHeight = a.getDimensionPixelOffset(R.styleable.EditSpinner_dropDownDrawableHeight, -1); setDropDownDrawable(mDropDownDrawable, dropDownDrawableWidth, dropDownDrawableHeight); setDropDownDrawableSpacing(dropDownDrawableSpacing); } // Get the anchor's id now, but the view won't be ready, so wait to actually get the // view and store it in mDropDownAnchorView lazily in getDropDownAnchorView later. // Defaults to NO_ID, in which case the getDropDownAnchorView method will simply return // this TextView, as a default anchoring point. mDropDownAnchorId = a.getResourceId(R.styleable.EditSpinner_dropDownAnchor, View.NO_ID); // For dropdown width, the developer can specify a specific width, or MATCH_PARENT // (for full screen width) or WRAP_CONTENT (to match the width of the anchored view). mPopup.setWidth(a.getLayoutDimension(R.styleable.EditSpinner_dropDownWidth, ViewGroup.LayoutParams.WRAP_CONTENT)); mPopup.setHeight(a.getLayoutDimension(R.styleable.EditSpinner_dropDownHeight, ViewGroup.LayoutParams.WRAP_CONTENT)); mPopup.setOnItemClickListener(new DropDownItemClickListener()); mPopup.setOnDismissListener(new PopupWindow.OnDismissListener() { @Override public void onDismiss() { mLastDismissTime = SystemClock.elapsedRealtime(); if (mOnDismissListener != null) { mOnDismissListener.onDismiss(); } } }); a.recycle(); mIsEditable = getKeyListener() != null; setFocusable(true); addTextChangedListener(new MyWatcher()); Log.d(TAG, "mIsEditable = " + mIsEditable); }