How to retrieve XML attribute for custom control

Posted by David on Stack Overflow See other posts from Stack Overflow or by David
Published on 2010-03-17T05:29:35Z Indexed on 2010/03/17 5:31 UTC
Read the original article Hit count: 247

Filed under:

I've created a combo box control with a edittext and spinner. I'm trying to let the android:prompt attribute be passed onto the spinner, which means I need to catch it in the constructor which passes my the AttributeSet and set it on the spinner. I can't figure out how to get the value of the prompt. I'm trying,

int[] ra = { android.R.attr.prompt };
TypedArray ta = context.getTheme().obtainStyledAttributes(ra); 
int id = ta.getResourceId(0, 0); 

I get back 0, which means it didn't find the attribute. I also did a ta.count() which returned 0. So I'm not getting anything back.

My XML simply defines an android:prompt value.

Thanks

© Stack Overflow or respective owner

Related posts about android