You will need to extend ArrayAdapter<MyRecord> with your own custom
rendering logic in getView(), then create an instance of your custom
adapter, associate it with your ArrayList<MyRecord>, and attach the
adapter to your ListView.

Here is a free excerpt from one of my books that walks through some of this:

http://commonsware.com/Android/excerpt.pdf

On Wed, Feb 2, 2011 at 4:36 PM, Richard Sámela <[email protected]> wrote:
> HI,
> I have a problem with implementation. I use a ArrayList<MyRecord> as
> class MyRecord is:
>
> public class MyRecord {
>         Date date;
>         double spotreba;
>         int pocet_km;
>         double cena;
>         String desc;
>
>        MyRecord(Date date, double objem, int pocet_km, double liter, String
> desc){
>                this.date=date;
>                this.spotreba=objem;
>                this.pocet_km=pocet_km;
>                this.cena=liter;
>                this.desc=desc;
>        }
>
> and in the ListView I have declared ListItem which looks like that:
>
> <?xml version="1.0" encoding="utf-8"?>
> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/
> android"
>    android:orientation="horizontal"
>    android:layout_width="fill_parent"
>    android:layout_height="fill_parent" android:paddingLeft="10sp">
>        <ImageView android:id="@+id/ImageView01"
>                           android:layout_width="wrap_content"
>                           android:layout_height="wrap_content"
>                           android:src="@drawable/pump"
>                           android:padding="5sp">
>        </ImageView>
>        <LinearLayout android:id="@+id/LinearLayout01"
>                                  android:layout_height="wrap_content"
>                                  android:orientation="vertical"
>                                  android:paddingLeft="10sp"
>                                  android:layout_width="fill_parent">
>                                  <TextView android:text="@+id/TextView01"
>                                                        
> android:id="@+id/TextView01"
>                                                        
> android:layout_width="wrap_content"
>                                                        
> android:layout_height="wrap_content"
>                                                        
> android:textColor="#FF0000"
>                                                        android:textSize="20sp"
>                                                        android:padding="1sp">
>                                  </TextView>
>                                  <TextView android:text="@+id/TextView02"
>                                                        
> android:id="@+id/TextView02"
>                                                        
> android:layout_width="wrap_content"
>                                                        
> android:layout_height="wrap_content">
>                                  </TextView>
>        </LinearLayout>
> </LinearLayout>
>
> and my problem is to referenced fields double spotreba and Date date
> to two TextViews in the inner LinearLayout. I understand if I had only
> strings and it give to adapter. But here I don't understand how to
> change my ArrayList<MyRecord> to some ArrayAdapter and show it in the
> View. can you give me some advice or some tutorial page? Or can you
> explain me it how should I continue?
>
> thank you very much
> Richard Sámela
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" 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-developers?hl=en
>



-- 
Mark Murphy (a Commons Guy)
http://commonsware.com | http://github.com/commonsguy
http://commonsware.com/blog | http://twitter.com/commonsguy

Android Training in London: http://bit.ly/smand1 and http://bit.ly/smand2

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" 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-developers?hl=en

Reply via email to