2012-03-20 107 views
0

我想要填充ListView而不包含所有相同事物的數組。列表視圖與數組

我有一個類「TijdsregistratieKaart」與這些字符串,布爾&雙。

public class TijdsregistratieKaart { 
    public String date,customerName,description,startTime,stopTime,taskDocumentNo_,activity,project,internalInformation,externalInformation; 
    public Boolean coaching; 
    public double percentageComplete; 
    ... 
} 

現在我的問題是如何將所有這些東西放在一個列表視圖。 ,以便日期在與customerName &描述不同的單元格中...我無法找到不使用所有相同的字符串或雙精度的數組的列表視圖的示例或...

此刻,我得到一個TijdsregistratieKaartAdapter類en填寫我的listView像這樣:

private class tijdsregistratieKaartAdapter extends ArrayAdapter<TijdsregistratieKaart> { 

    private ArrayList<TijdsregistratieKaart> items; 

    public tijdsregistratieKaartAdapter(Context context, int textViewResourceId, 
      ArrayList<TijdsregistratieKaart> items) { 
     super(context, textViewResourceId, items); 
     this.items = items; 
    } 

    @Override 
    public View getView(int position, View convertView, ViewGroup parent) { 
     View v = convertView; 
     if (v == null) { 
      LayoutInflater vi = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); 
      v = vi.inflate(R.layout.tijdsregistratiekaartrij, null); 
     } 
     TijdsregistratieKaart tijdsregistratiekaart = items.get(position); 
     if (tijdsregistratiekaart != null) { 
      TextView at = (TextView) v.findViewById(R.id.TRKtxtDatum); 
      TextView bt = (TextView) v.findViewById(R.id.TRKtxtKlantNaam); 
      TextView ct = (TextView) v.findViewById(R.id.TRKtxtDescription); 
      TextView dt = (TextView) v.findViewById(R.id.TRKtxtTaskDocNo); 
      TextView et = (TextView) v.findViewById(R.id.TRKtxtActivity); 
      TextView ft = (TextView) v.findViewById(R.id.TRKtxtCoaching); 
      TextView gt = (TextView) v.findViewById(R.id.TRKtxtExternalInformation); 
      TextView ht = (TextView) v.findViewById(R.id.TRKtxtInternalInformation); 
      TextView it = (TextView) v.findViewById(R.id.TRKtxtPercentageComplete); 
      TextView jt = (TextView) v.findViewById(R.id.TRKtxtProject); 
      TextView kt = (TextView) v.findViewById(R.id.TRKtxtStartTime); 
      TextView lt = (TextView) v.findViewById(R.id.TRKtxtStopTime); 
      if (at != null) { 
       at.setText("Datum:\n" + tijdsregistratiekaart.date); 
      } 
      if (bt != null) { 
       bt.setText("Klant naam:\n " + tijdsregistratiekaart.customerName); 
      } 
      if (ct != null) { 
       ct.setText("Omschrijving:\n " + tijdsregistratiekaart.description); 
      } 
      if (dt != null) { 
       dt.setText("Document Nr:\n" + tijdsregistratiekaart.taskDocumentNo_); 
      } 
      if (et != null) { 
       et.setText("Activiteit:\n " + tijdsregistratiekaart.activity); 
      } 
      if (ft != null) { 
       ft.setText("Begeleiding:\n " + tijdsregistratiekaart.coaching); 
      } 
      if (gt != null) { 
       gt.setText("Externe Informatie:\n" + tijdsregistratiekaart.externalInformation); 
      } 
      if (ht != null) { 
       ht.setText("Interne Informatie:\n " + tijdsregistratiekaart.internalInformation); 
      } 
      if (it != null) { 
       it.setText("% Afgewerkt:\n " + tijdsregistratiekaart.percentageComplete); 
      } 
      if (jt != null) { 
       jt.setText("Project:\n" + tijdsregistratiekaart.project); 
      } 
      if (kt != null) { 
       kt.setText("Start uur:\n " + tijdsregistratiekaart.startTime); 
      } 
      if (lt != null) { 
       lt.setText("Stop uur:\n " + tijdsregistratiekaart.stopTime); 
      } 
     } 
     return v; 
    } 
} 

但是,如果我這樣做。它是1個不同項目的大單元。我想爲每個項目的不同單元格,所以我可以添加onclickItemListeners在那些需要一個。

回答

0

您可能需要考慮重新設計流程。我知道這不是你想要聽到的。但如果要上下左右滾動瀏覽我的所有信息,那將是一件痛苦的事情。

相反,您可以向用戶顯示ListView中的重要數據。然後有一個功能,他們可以點擊一個項目,並看到有關該項目的更多細節。然後,您可以在更詳細的視圖或其他方式中使用onClickListeners