I want to fill a ListView without an array of all the same things.
I have a class “TijdsregistratieKaart” with these strings, boolean & double.
public class TijdsregistratieKaart {
public String date,customerName,description,startTime,stopTime,taskDocumentNo_,activity,project,internalInformation,externalInformation;
public Boolean coaching;
public double percentageComplete;
...
}
now my question is how to i put all these things in a listview.
so that Date is in a different cell than customerName & description,… I can’t find an example of a listview without using an array of all the same strings or double’s or…
At the moment i got an TijdsregistratieKaartAdapter class en fill my listView like this:
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;
}
}
but if i do it like this. it is 1 big cell with different items. and i want a different cell for each items so i can add onclickItemListeners on the ones that need one.
I got it, No need to use ListView, I’m going to use a scrollView and then add textView inside it. this is going to be a lot easier & the same result.
example: http://android-pro.blogspot.com/2010/02/android-scrollview.html