-1

I have created a list view to populate under a tab using listfragment as shown below. But i need to also write code to Show content text as "No Files on this tab" when the list returns empty. Is there a way to do this?

if(recordList.size()>0){
recordList = db.getRecordData();
while (count <= recordList.size()) {
    HashMap<String, String> map = new HashMap<String, String>();
    map.put(SUBJECT, recordList.get(index).getSubject());
    map.put(ADDRESS, recordList.get(index).getAddress());
    map.put(BUSINESS, recordList.get(index).getbusinessName());
    myList.add(map);
    count++;
    index++;
}

ListAdapter adapter = new SimpleAdapter(getActivity(), myList, R.layout.record_item, new String[] {SUBJECT, ADDRESS, BUSINESS }, new int[] { R.id.subject, R.id.address , R.id.business });
setListAdapter(adapter);

ListView listView = getListView();

listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
    ....
});
}
Abhi1988
  • 159
  • 2
  • 3
  • 14

1 Answers1

0

You can use setEmptyView function available in ListView. Please refer to this for more info:

Correct use of setEmtpyView in AdapterView

Community
  • 1
  • 1
Mohib Irshad
  • 1,940
  • 23
  • 18
  • I tried this: ListAdapter adapter = new SimpleAdapter(getActivity(), myList, R.layout.record_item, new String[] {SUBJECT, ADDRESS, BUSINESS }, new int[] { R.id.subject, R.id.address , R.id.business }); setListAdapter(adapter); ListView listView = getListView(); final EditText empty= (EditText)findViewById(R.id.empty); listView.setEmtpyView(); still it doesnt show – Abhi1988 Apr 23 '15 at 09:27