madhu y
madhu y

Reputation: 29

How to bind two array lists to listview in android?

My code is like this

I want to display Title,resumen,condition in one single row of listview

can u please help me.

Titles=new ArrayList<String>();
Resumens=new ArrayList<String>();
Conditions=new ArrayList<String>();

for(int i=0;i<resp2.getPropertyCount();i++)
{                          
    SoapObject table = (SoapObject)resp2.getProperty(i);
    Titles.add(table.getProperty("Titulo").toString());
    Resumens.add(table.getProperty("Resumen").toString());
    Conditions.add(table.getProperty("Condiciones").toString());
}

Upvotes: 0

Views: 883

Answers (2)

iMysak
iMysak

Reputation: 2228

Are you want some like this ?

class Triplet {
    public String title;
    public String resume;
    public String condition;

    public Triplet(String title, String resume, String condition) {
        this.title = title;
        this.resume = resume;
        this.condition = condition;
    }
}

....


ArrayList<Triplet> list=new ArrayList<Triplet>();

for(int i=0;i<resp2.getPropertyCount();i++)
{
    SoapObject table = (SoapObject)resp2.getProperty(i);
    Triplet triplet = new Triplet(table.getProperty("Titulo").toString(),
                                  table.getProperty("Resumen").toString(),
                                  table.getProperty("Condiciones").toString());
    list.add(triplet);
}

Upvotes: 1

sunriser
sunriser

Reputation: 780

You need to override the getView method in adapter class,by using the getView method you will get the position of the list position,pass that position to your array lists to get the corresponding values.But it all depends your adapter and how you inflate the layout.

Upvotes: 0

Related Questions