I'm trying to learn how to build my own custom compound control component by reading:
http://developer.android.com/guide/topics/ui/custom-components.html#compound I created my own view class and inherited it from RelativeLayout like so: public class MyCompoundView extends RelativeLayout { I also wrote a constructor like so: // Constructor version for instantiation from XML layout file. public MyCompoundView(Context context, AttributeSet attrs) { super(context, attrs); and created an main.xml file that uses it: <com.test.MyCompoundView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/hello" /> Everything works fine. What I can't figure out is how to get access to the attributes in the xml to read the hello string so I can display it. I can't find an example of someone doing this that works for me. The LabelView from the ApiDemos does something that looks good: http://developer.android.com/guide/samples/ApiDemos/src/com/example/android/apis/view/LabelView.html But when I try to modify this for my program as shown here: text_ = new TextView(context); TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.MyCompoundView); CharSequence s = a.getString(R.styleable.MyCompoundView_text); if (s != null) { text_.setText(s.toString()); } I get the compiler error: R.styleable cannot be resolved. So I tried to use this instead: // see: http://stackoverflow.com/questions/1476371/android-writing-a-custom-compound-component LayoutInflater inflater = (LayoutInflater) context.getSystemService (Context.LAYOUT_INFLATER_SERVICE); inflater.inflate(R.layout.my_layout, this); I get the compiler error: R.layout cannot be resolved. I'd like to be able to share my composite control with others, so I'd want it to be flexible in that I can define my own attributes. Also, it should allow users to declare the control in XML and not just instantiate it in Java code. Any hints on how to do this? Thanks, Mitch -- You received this message because you are subscribed to the Google Groups "Android Beginners" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-beginners?hl=en

