4

I am writing a custom Preference. I can easily read attribute values in my private namespace:

public MyPreference(Context context, AttributeSet attrs)
{
    super(context, attrs);
    TypedArray styledAttrs = context.obtainStyledAttributes(attrs, R.styleable.MyPreference);
    mDefaultValue = styledAttrs.getInt(R.styleable.MyPreference_defaultValue, 0);
}

But I do not know, how to read android attributes, e.g. android:defaultValue. In all examples on the web attributes contain values, but I use resources like @integer/my_number so simply reading attrs does not work - attribute contains resource reference but not the value. android.R.styleable is not accessible, so I do not understand how to do it.

Andrey Novikov
  • 5,563
  • 5
  • 30
  • 51
  • Wait if you have the resource references you can read its values? no? – Sergey Benner Jan 13 '12 at 14:41
  • This is probably what you are looking for: http://stackoverflow.com/questions/8037101/how-to-get-attributeset-properties/8038712#8038712 – Jens Jan 13 '12 at 14:55

0 Answers0