In arrayAdptor we use following code:
final LayoutInflater inflater = activity.getLayoutInflater();
row = (LinearLayoutCustom) inflater.inflate(R.layout.row, null);
final TextView label = (TextView) row.findViewById(R.id.title);
label.setText(position + "" + items[position]);
return row;
Now suppose some value are null (for example at position 2 , items[2] = null ) so i dont want to show it in row. i want to hide it. if i use
row.setVisibility(View.GONE)
it leaves a blank space at this row which i dont want. so what should i do?
You’ll need to have the adapter return the total number of non-null items with
getCountand then keep a mapping of position to your internal data structure.For example.
You have a list
When getCount is called it returns 3.
Then when
getViewis called on position 1 you return the item atlist[1].getViewon position 2 returnslist[3](as it’s the 2nd non-null),and so forth.
This is the only way I’ve found to do this.