views:

317

answers:

1

Im using an inflater inside an adapter for my listview. I need to add in a different button depending in the state of the data for each row, so Im thinking I need to do this programmatically, but how do I make sure its inserted into the correct place inside the layout?

A: 

Have two view files for each scenario. You will overkill yourself with the problem to add views at the desired place by code.

Or have one view that holds the button, and set visibility to GONE to dismiss when you don't needed.

((TextView) inflatedview.findViewById(R.id.custombut)).setVisibility(View.GONE);
Pentium10
Yeah, my first instinct was to have additional layouts and just inflate the correct one at runtime. Though I would need several layouts. Its not a bad solution just wondered if this was a best practice or not. The other solution was to have all the widgets Ill ever need but have them hidden, and reveal as needed at runtime.
Eno