I see a lot of SO posts about the usefulness of using convertView in Adapters, like this one, this one or this one (and many others...)
I have an ArrayAdapter, but I create the view from scratch, with a simple horizontal LinearLayout in which I add some textviews. The number of textviews and their weight depend on the position in the list. There could be 3 TV in the first row, 7 in the second and 25 in the third, with each one having a different weight, depending on database.
In this case, since I cannot inflate anything, whats does convertView contains ?
Should I use it ? If yes, how could I ?
EDIT : here is my code :
@Override
public View getView(final int position, View convertView, ViewGroup parent){
LinearLayout layout = new LinearLayout(context);
for (int i = 0; i < totalTVNumber; i++) {
LifeEvent event = getEventFromDB(cost, position);
if (event != null) {
TextView eventTV = event.getTextView(getContext());
eventTV.setLayoutParams(new LinearLayout.LayoutParams(0, 100, weight));//0 en width sinon weight n'est pas pris en compte !!
layout.addView(eventTV);
}
}
}