List of usage examples for android.support.v4.content.res TypedArrayUtils getInt
public static int getInt(TypedArray a, @StyleableRes int index, @StyleableRes int fallbackIndex, int defaultValue)
From source file:rikka.materialpreference.EditTextPreference.java
public EditTextPreference(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { super(context, attrs, defStyleAttr, defStyleRes); TypedArray a;/* w w w.j a v a 2 s . c om*/ a = context.obtainStyledAttributes(attrs, R.styleable.EditTextPreference); mInputType = TypedArrayUtils.getInt(a, R.styleable.EditTextPreference_inputType, R.styleable.EditTextPreference_android_inputType, InputType.TYPE_CLASS_TEXT); mSingleLine = TypedArrayUtils.getBoolean(a, R.styleable.EditTextPreference_singleLine, R.styleable.EditTextPreference_android_singleLine, true); mSelectAllOnFocus = TypedArrayUtils.getBoolean(a, R.styleable.EditTextPreference_selectAllOnFocus, R.styleable.EditTextPreference_android_selectAllOnFocus, false); mCommitOnEnter = a.getBoolean(R.styleable.EditTextPreference_commitOnEnter, false); a.recycle(); /* Retrieve the Preference summary attribute since it's private * in the Preference class. */ a = context.obtainStyledAttributes(attrs, R.styleable.Preference, defStyleAttr, defStyleRes); mSummary = TypedArrayUtils.getString(a, R.styleable.Preference_summary, R.styleable.Preference_android_summary); a.recycle(); }
From source file:rikka.materialpreference.RingtonePreference.java
public RingtonePreference(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { super(context, attrs, defStyleAttr, defStyleRes); TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.RingtonePreference, defStyleAttr, defStyleRes);/*from w ww . java2 s.c o m*/ mRingtoneType = TypedArrayUtils.getInt(a, R.styleable.RingtonePreference_ringtoneType, R.styleable.RingtonePreference_android_ringtoneType, RingtoneManager.TYPE_RINGTONE); mShowDefault = TypedArrayUtils.getBoolean(a, R.styleable.RingtonePreference_showDefault, R.styleable.RingtonePreference_android_showDefault, true); mShowSilent = TypedArrayUtils.getBoolean(a, R.styleable.RingtonePreference_showSilent, R.styleable.RingtonePreference_android_showSilent, true); mSummaryNone = a.getString(R.styleable.RingtonePreference_summaryNone); a.recycle(); /* Retrieve the Preference summary attribute since it's private * in the Preference class. */ a = context.obtainStyledAttributes(attrs, R.styleable.Preference, defStyleAttr, defStyleRes); mSummary = TypedArrayUtils.getString(a, R.styleable.Preference_summary, R.styleable.Preference_android_summary); a.recycle(); }
From source file:rikka.materialpreference.Preference.java
/** * Perform inflation from XML and apply a class-specific base style. This * constructor of Preference allows subclasses to use their own base style * when they are inflating. For example, a {@link CheckBoxPreference} * constructor calls this version of the super class constructor and * supplies {@code android.R.attr.checkBoxPreferenceStyle} for * <var>defStyleAttr</var>. This allows the theme's checkbox preference * style to modify all of the base preference attributes as well as the * {@link CheckBoxPreference} class's attributes. * * @param context The Context this is associated with, through which it can * access the current theme, resources, * {@link android.content.SharedPreferences}, etc. * @param attrs The attributes of the XML tag that is inflating the * preference./*from ww w . j av a 2s . c o m*/ * @param defStyleAttr An attribute in the current theme that contains a * reference to a style resource that supplies default values for * the view. Can be 0 to not look for defaults. * @param defStyleRes A resource identifier of a style resource that * supplies default values for the view, used only if * defStyleAttr is 0 or can not be found in the theme. Can be 0 * to not look for defaults. * @see #Preference(Context, android.util.AttributeSet) */ public Preference(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { mContext = context; final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.Preference, defStyleAttr, defStyleRes); mIconResId = TypedArrayUtils.getResourceId(a, R.styleable.Preference_icon, R.styleable.Preference_android_icon, 0); mKey = TypedArrayUtils.getString(a, R.styleable.Preference_key, R.styleable.Preference_android_key); mTitle = TypedArrayUtils.getString(a, R.styleable.Preference_title, R.styleable.Preference_android_title); mSummary = TypedArrayUtils.getString(a, R.styleable.Preference_summary, R.styleable.Preference_android_summary); mOrder = TypedArrayUtils.getInt(a, R.styleable.Preference_order, R.styleable.Preference_android_order, DEFAULT_ORDER); mFragment = TypedArrayUtils.getString(a, R.styleable.Preference_fragment, R.styleable.Preference_android_fragment); mLayoutResId = TypedArrayUtils.getResourceId(a, R.styleable.Preference_layout, R.styleable.Preference_android_layout, R.layout.preference_material); mWidgetLayoutResId = TypedArrayUtils.getResourceId(a, R.styleable.Preference_widgetLayout, R.styleable.Preference_android_widgetLayout, 0); mEnabled = TypedArrayUtils.getBoolean(a, R.styleable.Preference_enabled, R.styleable.Preference_android_enabled, true); mSelectable = TypedArrayUtils.getBoolean(a, R.styleable.Preference_selectable, R.styleable.Preference_android_selectable, true); mPersistent = TypedArrayUtils.getBoolean(a, R.styleable.Preference_persistent, R.styleable.Preference_android_persistent, true); mDependencyKey = TypedArrayUtils.getString(a, R.styleable.Preference_dependency, R.styleable.Preference_android_dependency); if (a.hasValue(R.styleable.Preference_defaultValue)) { mDefaultValue = onGetDefaultValue(a, R.styleable.Preference_defaultValue); } else if (a.hasValue(R.styleable.Preference_android_defaultValue)) { mDefaultValue = onGetDefaultValue(a, R.styleable.Preference_android_defaultValue); } mShouldDisableView = TypedArrayUtils.getBoolean(a, R.styleable.Preference_shouldDisableView, R.styleable.Preference_shouldDisableView, true); a.recycle(); }
From source file:android.support.v7.preference.Preference.java
/** * Perform inflation from XML and apply a class-specific base style. This * constructor of Preference allows subclasses to use their own base style * when they are inflating. For example, a {@link CheckBoxPreference} * constructor calls this version of the super class constructor and * supplies {@code android.R.attr.checkBoxPreferenceStyle} for * <var>defStyleAttr</var>. This allows the theme's checkbox preference * style to modify all of the base preference attributes as well as the * {@link CheckBoxPreference} class's attributes. * * @param context The Context this is associated with, through which it can * access the current theme, resources, * {@link android.content.SharedPreferences}, etc. * @param attrs The attributes of the XML tag that is inflating the * preference.//from w w w . j a v a 2 s. co m * @param defStyleAttr An attribute in the current theme that contains a * reference to a style resource that supplies default values for * the view. Can be 0 to not look for defaults. * @param defStyleRes A resource identifier of a style resource that * supplies default values for the view, used only if * defStyleAttr is 0 or can not be found in the theme. Can be 0 * to not look for defaults. * @see #Preference(Context, android.util.AttributeSet) */ public Preference(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { mContext = context; final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.Preference, defStyleAttr, defStyleRes); mIconResId = TypedArrayUtils.getResourceId(a, R.styleable.Preference_icon, R.styleable.Preference_android_icon, 0); mKey = TypedArrayUtils.getString(a, R.styleable.Preference_key, R.styleable.Preference_android_key); mTitle = TypedArrayUtils.getString(a, R.styleable.Preference_title, R.styleable.Preference_android_title); mSummary = TypedArrayUtils.getString(a, R.styleable.Preference_summary, R.styleable.Preference_android_summary); mOrder = TypedArrayUtils.getInt(a, R.styleable.Preference_order, R.styleable.Preference_android_order, DEFAULT_ORDER); mFragment = TypedArrayUtils.getString(a, R.styleable.Preference_fragment, R.styleable.Preference_android_fragment); mLayoutResId = TypedArrayUtils.getResourceId(a, R.styleable.Preference_layout, R.styleable.Preference_android_layout, R.layout.preference); mWidgetLayoutResId = TypedArrayUtils.getResourceId(a, R.styleable.Preference_widgetLayout, R.styleable.Preference_android_widgetLayout, 0); mEnabled = TypedArrayUtils.getBoolean(a, R.styleable.Preference_enabled, R.styleable.Preference_android_enabled, true); mSelectable = TypedArrayUtils.getBoolean(a, R.styleable.Preference_selectable, R.styleable.Preference_android_selectable, true); mPersistent = TypedArrayUtils.getBoolean(a, R.styleable.Preference_persistent, R.styleable.Preference_android_persistent, true); mDependencyKey = TypedArrayUtils.getString(a, R.styleable.Preference_dependency, R.styleable.Preference_android_dependency); if (a.hasValue(R.styleable.Preference_defaultValue)) { mDefaultValue = onGetDefaultValue(a, R.styleable.Preference_defaultValue); } else if (a.hasValue(R.styleable.Preference_android_defaultValue)) { mDefaultValue = onGetDefaultValue(a, R.styleable.Preference_android_defaultValue); } mShouldDisableView = TypedArrayUtils.getBoolean(a, R.styleable.Preference_shouldDisableView, R.styleable.Preference_android_shouldDisableView, true); a.recycle(); }