Hi! I created a custom View called LabeledSpinner that consists of a TextView and a Spinnerand extends LinearLayout. I created an attrs.xml file and put the following lines into it
<?xml version="1.0" encoding="utf-8"?> <resources> <declare-styleable name="LabeledSpinner"> <attr name="text" format="string"/> </declare-styleable> </resources> Here is the constructor of my LabeledSpinner: public LabeledSpinner(Context context, AttributeSet attrs){ super(context, attrs); setOrientation(HORIZONTAL); LayoutInflater.from(context).inflate(R.layout.labeled_spinner, this, true); TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.LabeledSpinner); String text = a.getString(R.styleable.LabeledSpinner_text); a.recycle(); } Here is the labeledspinner.xml <merge xmlns:android="http://schemas.android.com/apk/res/android"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:textSize="18sp" android:gravity="center" /> <Spinner android:background="@drawable/combobox_selector" android:layout_width="wrap_content" android:layout_height="wrap_content" android:drawSelectorOnTop="true" /> </merge> And finally here is the part of my main RelativeLayout that contains my LabeledSpinner: <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:randomnamespace=" http://schemas.android.com/apk/res/PackageNameThatCanBeFoundInTheManifestFile " android:layout_width="fill_parent" android:layout_height="fill_parent"> <PackageNameThatCanBeFoundInTheManifestFile.gui.LabeledSpinner android:id="@+alarmsettings/intervalspinner" android:layout_height="fill_parent" android:layout_width="wrap_content" android:layout_below="@+alarmsettings/seperator1" android:layout_alignBottom="@+alarmsettings/addinterval" android:layout_marginTop="1dip" android:gravity="center" randomnamespace:text="Hello world" /> </RelativeLayout> I created the code using several tutorials/forums on the subject and they all stated that such code l will work but for some reason there is no text in my inner TextView. Maybe I missed something regarding the tutorials but I'm totally out of any ideas so please help me. -- 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en