android.widget.AutoCompleteTextView#setDropDownHeight ( )源码实例Demo

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

源代码1 项目: MDPreference   文件: ViewUtil.java
/**
 * Apply any AutoCompleteTextView style attributes to a view.
 * @param v
 * @param attrs
 * @param defStyleAttr
 * @param defStyleRes
 */
private static void applyStyle(AutoCompleteTextView v,  AttributeSet attrs, int defStyleAttr, int defStyleRes){
    TypedArray a = v.getContext().obtainStyledAttributes(attrs, R.styleable.AutoCompleteTextView, defStyleAttr, defStyleRes);

    int n = a.getIndexCount();
    for (int i = 0; i < n; i++) {
        int attr = a.getIndex(i);

        if(attr == R.styleable.AutoCompleteTextView_android_completionHint)
            v.setCompletionHint(a.getString(attr));
        else if(attr == R.styleable.AutoCompleteTextView_android_completionThreshold)
            v.setThreshold(a.getInteger(attr, 0));
        else if(attr == R.styleable.AutoCompleteTextView_android_dropDownAnchor)
            v.setDropDownAnchor(a.getResourceId(attr, 0));
        else if(attr == R.styleable.AutoCompleteTextView_android_dropDownHeight)
            v.setDropDownHeight(a.getLayoutDimension(attr, ViewGroup.LayoutParams.WRAP_CONTENT));
        else if(attr == R.styleable.AutoCompleteTextView_android_dropDownWidth)
            v.setDropDownWidth(a.getLayoutDimension(attr, ViewGroup.LayoutParams.WRAP_CONTENT));
        else if(attr == R.styleable.AutoCompleteTextView_android_dropDownHorizontalOffset)
            v.setDropDownHorizontalOffset(a.getDimensionPixelSize(attr, 0));
        else if(attr == R.styleable.AutoCompleteTextView_android_dropDownVerticalOffset)
            v.setDropDownVerticalOffset(a.getDimensionPixelSize(attr, 0));
        else if(attr == R.styleable.AutoCompleteTextView_android_popupBackground)
            v.setDropDownBackgroundDrawable(a.getDrawable(attr));
    }
    a.recycle();
}
 
源代码2 项目: material   文件: ViewUtil.java
/**
 * Apply any AutoCompleteTextView style attributes to a view.
 * @param v
 * @param attrs
 * @param defStyleAttr
 * @param defStyleRes
 */
private static void applyStyle(AutoCompleteTextView v,  AttributeSet attrs, int defStyleAttr, int defStyleRes){
    TypedArray a = v.getContext().obtainStyledAttributes(attrs, R.styleable.AutoCompleteTextView, defStyleAttr, defStyleRes);

    int n = a.getIndexCount();
    for (int i = 0; i < n; i++) {
        int attr = a.getIndex(i);

        if(attr == R.styleable.AutoCompleteTextView_android_completionHint)
            v.setCompletionHint(a.getString(attr));
        else if(attr == R.styleable.AutoCompleteTextView_android_completionThreshold)
            v.setThreshold(a.getInteger(attr, 0));
        else if(attr == R.styleable.AutoCompleteTextView_android_dropDownAnchor)
            v.setDropDownAnchor(a.getResourceId(attr, 0));
        else if(attr == R.styleable.AutoCompleteTextView_android_dropDownHeight)
            v.setDropDownHeight(a.getLayoutDimension(attr, ViewGroup.LayoutParams.WRAP_CONTENT));
        else if(attr == R.styleable.AutoCompleteTextView_android_dropDownWidth)
            v.setDropDownWidth(a.getLayoutDimension(attr, ViewGroup.LayoutParams.WRAP_CONTENT));
        else if(attr == R.styleable.AutoCompleteTextView_android_dropDownHorizontalOffset)
            v.setDropDownHorizontalOffset(a.getDimensionPixelSize(attr, 0));
        else if(attr == R.styleable.AutoCompleteTextView_android_dropDownVerticalOffset)
            v.setDropDownVerticalOffset(a.getDimensionPixelSize(attr, 0));
        else if(attr == R.styleable.AutoCompleteTextView_android_popupBackground)
            v.setDropDownBackgroundDrawable(a.getDrawable(attr));
    }
    a.recycle();
}
 
@Override
protected void afterLayoutInflated(Context context, AttributeSet attrs, int defStyle) {
    super.afterLayoutInflated(context, attrs, defStyle);

    final CharSequence completionHint;
    final int completionThreshold;
    final int popupBackground;
    final int dropDownWidth;
    final int dropDownHeight;

    if (attrs == null) {
        completionHint = "";
        completionThreshold = 1;
        dropDownHeight = ViewGroup.LayoutParams.WRAP_CONTENT;
        dropDownWidth = ViewGroup.LayoutParams.WRAP_CONTENT;
        popupBackground = getDefaultPopupBackgroundResId();
    } else {
        TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.FloatingLabelAutoCompleteTextView, defStyle, 0);
        completionHint = a.getText(R.styleable.FloatingLabelAutoCompleteTextView_android_completionHint);
        completionThreshold = a.getInt(R.styleable.FloatingLabelAutoCompleteTextView_android_completionThreshold, 1);
        dropDownHeight = a.getDimensionPixelSize(R.styleable.FloatingLabelAutoCompleteTextView_android_dropDownHeight, ViewGroup.LayoutParams.WRAP_CONTENT);
        dropDownWidth = a.getDimensionPixelSize(R.styleable.FloatingLabelAutoCompleteTextView_android_dropDownWidth, ViewGroup.LayoutParams.WRAP_CONTENT);
        popupBackground = a.getResourceId(R.styleable.FloatingLabelAutoCompleteTextView_android_popupBackground, getDefaultPopupBackgroundResId());
        a.recycle();
    }

    final AutoCompleteTextView inputWidget = getInputWidget();
    inputWidget.setCompletionHint(completionHint);
    inputWidget.setThreshold(completionThreshold);
    inputWidget.setDropDownWidth(dropDownWidth);
    inputWidget.setDropDownHeight(dropDownHeight);
    inputWidget.setDropDownBackgroundResource(popupBackground);
    inputWidget.addTextChangedListener(new EditTextWatcher());
}