2011-07-26 67 views
0

我的代碼是這樣的如何將兩個數組列表綁定到android中的listview?

我想顯示標題,會談摘要,在列表視圖

的一個單列條件U可以請幫助我。

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()); 
} 

回答

0

你需要重寫適配器類的getView方法,通過使用getView方法,你將得到列表中的位置的位置,通過該位置到您的數組列表,以獲得相應的values.But這一切都取決於您的適配器以及如何膨脹佈局。

1

你想要這樣嗎?

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); 
} 
相關問題