On Dec 29, 11:00 pm, Mystique <joven.ch...@gmail.com> wrote:
> Good day,
> I do not understand the outer LinearLayout you was pointing out.
> Don't we need to declare a Layout so we can put component such as
> listview, textview etc?

No - this is an unnecessary layer that is quite expensive in memory
and CPU resources.  You have an Activity that probably has a call to
setContentView(v).  Here 'v' can be any View.  It does not have to be
a layout.  In general, View widgets do not need to be declared inside
layout widgets (layouts are ViewGroup instances).  For example

---list.xml---
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android";
 ...
/>

>
> On Dec 30, 2:51 pm, jotobjects <jotobje...@gmail.com> wrote:
>
> > Does android.widget.TwoLineListItem do what you want?
>
> > BTW - looks like the outer LinearLayout is unnecessary in list.xml and
> > listadapter.xml.
>
> > On Dec 29, 5:41 pm, Mystique <joven.ch...@gmail.com> wrote:
>
> > > Hi,
> > > I have an app that I mine data with an ArrayList and load to an
> > > ArrayAdapter to display as listview. How can I do more than 1 textview
> > > item in 1 roll? My code is:
>
> > > ---list.xml---
> > > <?xml version="1.0" encoding="utf-8"?>
> > > <LinearLayout xmlns:android="http://schemas.android.com/apk/res/
> > > android"
> > >         android:layout_width="fill_parent"
> > >         android:layout_height="fill_parent"
> > >     android:background="@drawable/selector"
> > >         android:padding="10sp">
> > > <TextView
> > >         android:id="@+id/listA"
> > >     android:layout_width="wrap_content"
> > >         android:layout_height="wrap_content"
> > >     android:singleLine="true"
> > >     android:gravity="center_vertical|left"
> > >     android:textAppearance="?android:attr/
> > > textAppearanceMediumInverse">
> > > </TextView>
> > > </LinearLayout>
>
> > > --listadapter.xml---
> > > <?xml version="1.0" encoding="utf-8"?>
> > > <LinearLayout xmlns:android="http://schemas.android.com/apk/res/
> > > android"
> > >     android:orientation="vertical"
> > >     android:layout_width="fill_parent"
> > >     android:layout_height="fill_parent"
> > >     >
> > >         <ListView
> > >     android:id="@+id/listView"
> > >     android:cacheColorHint="#000000"
> > >     android:layout_width="fill_parent"
> > >     android:layout_height="wrap_content"
> > >     />
> > > </LinearLayout>
>
> > > --code---
> > >     lv1=(ListView)findViewById(R.id.listView);
> > >     lv1.setAdapter(new ArrayAdapter<String>(this,
> > > R.layout.listadapter, R.id.listA, allTheList2));
>
> > > all is ok for single line.
>
> > > --- try to do but fail ---
> > > Create another TextView such as:
>
> > > <TextView
> > >         android:id="@+id/listB"
> > > blah blah...
>
> > > then add another:
> > >     lv1.setAdapter(new ArrayAdapter<String>(this,
> > > R.layout.listadapter, R.id.listB, allTheList2));
>
> > > But fail. Basically, what I want to do is to mine data DATA_FIELD1,
> > > DATA_FIELD2 populate into a listview to display (single roll):
> > > DATA_FIELD1 (Larger font)
> > > DATA_FIELD2 (Smaller font)
>
> > > I can't find any example to do this, can anyone please advice?
>
> > > Many Thanks,
> > > CJ

-- 
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

Reply via email to