동일한 모든 배열없이 ListView를 채우고 싶습니다.배열이있는 ListView
나는이 문자열들과 함께 "TijdsregistratieKaart"클래스를 가지고 있으며, 부울은 & double입니다.
public class TijdsregistratieKaart {
public String date,customerName,description,startTime,stopTime,taskDocumentNo_,activity,project,internalInformation,externalInformation;
public Boolean coaching;
public double percentageComplete;
...
}
이제 내 질문은 어떻게 이러한 모든 것을 listview에 넣는 지입니다. 날짜가 customerName & 설명과 다른 셀에 들어 있기 때문에 같은 문자열이나 double의 배열을 사용하지 않고 listview 예제를 찾을 수 없습니다.
현재 i TijdsregistratieKaartAdapter 클래스를 가져와 내 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를 추가 할 수있다.