Is there a way to create an instance of a TextView on a separate layout? I have created an ExpandableListView with x number of objects. I would like to display one of the children in the collapsed group as well. I realize I could set up in the code, however it would be much easier, and much cleaner if I could just point to the same id R.id.dscItem multiple times.
I have tried dropping the + in “@+id/dscItem”so that it was “@id/dscItem” but it didn’t do much. Is it true that I can only point to this id once!?
SimpleExpandableListAdapter mAdapter = new SimpleExpandableListAdapter(
this, createGroup(), R.layout.exprow, R.layout.row,
new String[] { Items.ITEMS_ITEM }, new int[] { R.id.txtItem },
createChildren(), R.layout.exprow, new String[] {
Items.ITEMS_DESC, Items.ITEMS_MANU },
new int[] { R.id.dscItem, R.id.manuItem });
XML layout 1:
></TextView>
<TextView
android:text="Description"
android:id="@id/dscItem"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|right"
android:textSize="15dip"
></TextView>
XML layout 2
<TextView
android:text="Description"
android:id="@+id/dscItem"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#994020"
android:layout_gravity="right"
></TextView>
You can create a textview in a separate layout and use it by layout merge in xml or layout inflater in java code
http://developer.android.com/resources/articles/layout-tricks-merge.html