Example usage for android.support.v4.content.res TypedArrayUtils getAttr

List of usage examples for android.support.v4.content.res TypedArrayUtils getAttr

Introduction

In this page you can find the example usage for android.support.v4.content.res TypedArrayUtils getAttr.

Prototype

public static int getAttr(Context context, int attr, int fallbackAttr) 

Source Link

Usage

From source file:android.support.v7.preference.ListPreference.java

public ListPreference(Context context, AttributeSet attrs) {
    this(context, attrs, TypedArrayUtils.getAttr(context, R.attr.dialogPreferenceStyle,
            android.R.attr.dialogPreferenceStyle));
}

From source file:android.support.v7.preference.CheckBoxPreference.java

public CheckBoxPreference(Context context, AttributeSet attrs) {
    this(context, attrs, TypedArrayUtils.getAttr(context, R.attr.checkBoxPreferenceStyle,
            android.R.attr.checkBoxPreferenceStyle));
}

From source file:android.support.v14.preference.MultiSelectListPreference.java

public MultiSelectListPreference(Context context, AttributeSet attrs) {
    this(context, attrs, TypedArrayUtils.getAttr(context,
            android.support.v7.preference.R.attr.dialogPreferenceStyle, android.R.attr.dialogPreferenceStyle));
}

From source file:android.support.v7.preference.PreferenceScreen.java

/**
 * Do NOT use this constructor, use {@link PreferenceManager#createPreferenceScreen(Context)}.
 * @hide-/* w ww .  j a  v  a 2s  . c om*/
 */
public PreferenceScreen(Context context, AttributeSet attrs) {
    super(context, attrs, TypedArrayUtils.getAttr(context, R.attr.preferenceScreenStyle,
            android.R.attr.preferenceScreenStyle));
}

From source file:com.android.settingslib.RestrictedSwitchPreference.java

public RestrictedSwitchPreference(Context context, AttributeSet attrs) {
    this(context, attrs, TypedArrayUtils.getAttr(context,
            android.support.v7.preference.R.attr.switchPreferenceStyle, android.R.attr.switchPreferenceStyle));
}

From source file:android.support.v7.preference.DialogPreference.java

public DialogPreference(Context context, AttributeSet attrs) {
    this(context, attrs, TypedArrayUtils.getAttr(context, R.attr.dialogPreferenceStyle,
            android.R.attr.dialogPreferenceStyle));
}

From source file:android.support.v14.preference.SwitchPreference.java

/**
 * Construct a new SwitchPreference with the given style options.
 *
 * @param context The Context that will style this preference
 * @param attrs Style attributes that differ from the default
 *///from www .ja v a2  s . c o  m
public SwitchPreference(Context context, AttributeSet attrs) {
    this(context, attrs, TypedArrayUtils.getAttr(context,
            android.support.v7.preference.R.attr.switchPreferenceStyle, android.R.attr.switchPreferenceStyle));
}

From source file:android.support.v14.preference.PreferenceFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    TypedArray a = mStyledContext.obtainStyledAttributes(null, R.styleable.PreferenceFragment,
            TypedArrayUtils.getAttr(mStyledContext,
                    android.support.v7.preference.R.attr.preferenceFragmentStyle,
                    AndroidResources.ANDROID_R_PREFERENCE_FRAGMENT_STYLE),
            0);/* ww w.ja v  a  2  s .  c  o  m*/

    mLayoutResId = a.getResourceId(R.styleable.PreferenceFragment_android_layout, mLayoutResId);

    final Drawable divider = a.getDrawable(R.styleable.PreferenceFragment_android_divider);
    final int dividerHeight = a.getDimensionPixelSize(R.styleable.PreferenceFragment_android_dividerHeight, -1);

    a.recycle();

    // Need to theme the inflater to pick up the preferenceFragmentListStyle
    final TypedValue tv = new TypedValue();
    getActivity().getTheme().resolveAttribute(android.support.v7.preference.R.attr.preferenceTheme, tv, true);
    final int theme = tv.resourceId;

    final Context themedContext = new ContextThemeWrapper(inflater.getContext(), theme);
    final LayoutInflater themedInflater = inflater.cloneInContext(themedContext);

    final View view = themedInflater.inflate(mLayoutResId, container, false);

    final View rawListContainer = view.findViewById(AndroidResources.ANDROID_R_LIST_CONTAINER);
    if (!(rawListContainer instanceof ViewGroup)) {
        throw new RuntimeException("Content has view with id attribute "
                + "'android.R.id.list_container' that is not a ViewGroup class");
    }

    final ViewGroup listContainer = (ViewGroup) rawListContainer;

    final RecyclerView listView = onCreateRecyclerView(themedInflater, listContainer, savedInstanceState);
    if (listView == null) {
        throw new RuntimeException("Could not create RecyclerView");
    }

    mList = listView;

    listView.addItemDecoration(mDividerDecoration);
    setDivider(divider);
    if (dividerHeight != -1) {
        setDividerHeight(dividerHeight);
    }

    listContainer.addView(mList);
    mHandler.post(mRequestFocus);

    return view;
}

From source file:android.support.v7.preference.Preference.java

/**
 * Constructor that is called when inflating a Preference from XML. This is
 * called when a Preference is being constructed from an XML file, supplying
 * attributes that were specified in the XML file. This version uses a
 * default style of 0, so the only attribute values applied are those in the
 * Context's Theme and the given AttributeSet.
 *
 * @param context The Context this is associated with, through which it can
 *            access the current theme, resources, {@link android.content.SharedPreferences},
 *            etc./*from   w w  w. j a  v a 2s .  c o m*/
 * @param attrs The attributes of the XML tag that is inflating the
 *            preference.
 * @see #Preference(Context, AttributeSet, int)
 */
public Preference(Context context, AttributeSet attrs) {
    this(context, attrs,
            TypedArrayUtils.getAttr(context, R.attr.preferenceStyle, android.R.attr.preferenceStyle));
}