Tuesday, November 16, 2010

[android-developers] Re: Accessing style items by style ID

I found a solution. defStyle parameter is not needed for it. All I
need exists in attrs parameter.
TypedArray attrsArray = context.obtainStyledAttributes(attrs,
R.styleable.MyComponent);
bg = attrsArray.getResourceId(R.styleable.MyComponent_attribute,
defaultId);

On 15 ноя, 22:38, Vitaliy Tarasenko <vitta...@gmail.com> wrote:
> Hello. I have a problem.
> Any View have a constructor
> public View (Context context, AttributeSet attrs, int defStyle) which
> called when View declared with a style attribute
> So, if I have some class inherited from View class, I can access to
> declared attributes (like "android:layout_width" or
> "android:background") via AttributeSet attrs in a constructor. But
> when I move attributes to style I cannot see attributes and values
> exists in a style - I want to read items declared in style but I have
> only styleID in defStyle parameter. Is there some way to read style
> Items using styleID?

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate