Android: How can I dynamically show / hide an item in a ListView item based on the Array value?


im trying to create a ListView filled with items fetched from an API, and depending on a variable, I want to show/hide an TextView in my ListView item layout for that row.

My ListView item layout contains 3 TextViews. One is hidden on default using android:visibilty:"GONE".

I am using a this for my ListAdapter:

ArrayList<HashMap<String, String>> mylist = new ArrayList<HashMap<String, String>>();

Attach to:

ListAdapter adapter = new SimpleAdapter(this, mylist , R.layout.main,
                            new String[] { "title", "info","comments", "score" },
                            new int[] {,,, });
final ListView lv = getListView();

So my question is, how can I iterate the whole list to check if "VariableA" == "something" then show the hidden TextView within that single item?

Or is there a way to dynamically Insert a TextView in that a single ListView item?


You should create Custom Adapter For Listview and write Some Logic in

public View getView(final int position, View convertView, ViewGroup parent) {

         //create view here For row

     }    else{
         //create another view here For row

  return row;