public void applyStyle(int resId){ ViewUtil.applyStyle(this, resId); applyStyle(getContext(), null, 0, resId); }
/** * <p>Returns the focus state in the drop down.</p> * * @return true always if hijacking focus */ @Override public boolean hasFocus() { return mHijackFocus || super.hasFocus(); }
/** * <p>Returns the focus state in the drop down.</p> * * @return true always if hijacking focus */ @Override public boolean hasWindowFocus() { return mHijackFocus || super.hasWindowFocus(); }
@Override public void onGlobalLayout() { ListView lv = mReplacementPopup.getListView(); ViewTreeObserver observer = lv.getViewTreeObserver(); if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) observer.removeOnGlobalLayoutListener(this); else observer.removeGlobalOnLayoutListener(this); View v = lv.getChildAt(0); v.measure(MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED), MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED)); mReplacementPopup.setContentWidth(v.getMeasuredWidth()); int[] popupLocation = new int[2]; lv.getLocationOnScreen(popupLocation); int[] inputLocation = new int[2]; mInputView.getLocationOnScreen(inputLocation); Drawable background = mReplacementPopup.getPopup().getBackground(); Rect backgroundPadding = new Rect(); int verticalOffset; int horizontalOffset = inputLocation[0] + (int)mSelectedSpan.mX - (popupLocation[0] + backgroundPadding.left); if(background != null) background.getPadding(backgroundPadding); if(inputLocation[1] < popupLocation[1]) //popup show at bottom verticalOffset = inputLocation[1] + mSelectedSpan.mY - (popupLocation[1] + backgroundPadding.top); else verticalOffset = inputLocation[1] + mSelectedSpan.mY + mSpanHeight - (popupLocation[1] + lv.getHeight() - backgroundPadding.bottom); mReplacementPopup.setVerticalOffset(verticalOffset); mReplacementPopup.setHorizontalOffset(horizontalOffset); mReplacementPopup.show(); } });
private void showPopup(){ if (!mPopup.isShowing()){ mPopup.show(); final ListView lv = mPopup.getListView(); if(lv != null){ if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) lv.setChoiceMode(ListView.CHOICE_MODE_SINGLE); lv.setSelection(getSelectedItemPosition()); if(mArrowDrawable != null && mArrowAnimSwitchMode) lv.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() { @Override public boolean onPreDraw() { lv.getViewTreeObserver().removeOnPreDrawListener(this); mArrowDrawable.setMode(ArrowDrawable.MODE_UP, true); return true; } }); } } }
@Override public boolean onPreDraw() { lv.getViewTreeObserver().removeOnPreDrawListener(this); mArrowDrawable.setMode(ArrowDrawable.MODE_UP, true); return true; } });
public ListView(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); init(context, attrs, defStyleAttr, 0); }
@Override public void onThemeChanged(ThemeManager.OnThemeChangedEvent event) { int style = ThemeManager.getInstance().getCurrentStyle(mStyleId); if(mCurrentStyle != style){ mCurrentStyle = style; applyStyle(mCurrentStyle); } }
/** * <p>Returns the focus state in the drop down.</p> * * @return true always if hijacking focus */ @Override public boolean isFocused() { return mHijackFocus || super.isFocused(); }
mReplacementPopup.show(); mReplacementPopup.getListView().getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { @Override public void onGlobalLayout() {
public ListView(Context context) { super(context); init(context, null, 0, 0); }
@Override protected void applyStyle(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes){ super.applyStyle(context, attrs, defStyleAttr, defStyleRes);
public ListView(Context context, AttributeSet attrs) { super(context, attrs); init(context, attrs, 0, 0); }
@Override protected void applyStyle(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes){ super.applyStyle(context, attrs, defStyleAttr, defStyleRes);
setAdapter(mAdapter); super.init(context, attrs, defStyleAttr, defStyleRes);
@Override protected void init(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes){ mTextSize = -1; mItemHeight = -1; mAnimDuration = -1; mTypeface = Typeface.DEFAULT; mItemRealHeight = -1; setWillNotDraw(false); mPaint = new Paint(Paint.ANTI_ALIAS_FLAG); mPaint.setStyle(Paint.Style.FILL); mAdapter = new YearAdapter(); setAdapter(mAdapter); setScrollBarStyle(SCROLLBARS_OUTSIDE_OVERLAY); setSelector(BlankDrawable.getInstance()); setDividerHeight(0); setCacheColorHint(Color.TRANSPARENT); setClipToPadding(false); mPadding = ThemeUtil.dpToPx(context, 4); mSelectionColor = ThemeUtil.colorPrimary(context, 0xFF000000); super.init(context, attrs, defStyleAttr, defStyleRes); }