Hide items in a listview
android, listview
Solution
You can set ContentView with No Element.
In getView() of Your Custom Adapter.
if(condition)
{
convertView=layoutInflater.inflate(R.layout.row_null,null);
return convertView;
}
else
{
convertView=layoutInflater.inflate(R.layout.row_content,null);
return convertView;
}
your XML row_null.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content">
</LinearLayout>
Problem
I have tried to hide items in a custom list adapter. I can hide the visibility of the text but I cannot hide the whole list item. It still shows the dividers etc. I have tried: ``` tv.setVisibility(View.INVISIBLE); tv.setVisibility(View.GONE); convertView.setVisibility(View.INVISIBLE); convertView.setVisibility(View.GONE); ``` When I use the convertView i get a null pointer exception.