I have a custom adapter which formats for me, alphabet headers and then corresponding names underthem, but I want to put a unique footer at the bottom that will display the number of contacts, for example “Total number of contacts in list: 21”
class LetterAdapter extends ArrayAdapter<String> {
LetterAdapter() {
super(ContactProjectActivity.this, R.layout.row, R.id.label, sortedNames);
}
public View getView(int position, View convertView, ViewGroup parent) {
View row = convertView;
if (row == null) {
LayoutInflater inflater=getLayoutInflater();
row = inflater.inflate(R.layout.row, parent, false);
}
TextView label = (TextView) row.findViewById(R.id.label);
label.setText(sortedNames.get(position));
if (sortedNames.get(position).length() == 1) {
//label.setText("The size is " + searchNames.size());
label.setTextSize(15);
row.setBackgroundColor(Color.GRAY);
}
else {
label.setTextSize(20);
label.setTextColor(Color.BLACK);
row.setBackgroundColor(Color.WHITE);
}
return(row);
}
}
I am extending ListActivity so I don’t have a ListView variable in my code. Any code snippets or suggestions would be helpful.
I want to customize the footer also, with its own background color (similar to how I did the letter headers in the code).
You could get the
ListViewfrom youListActivitywith the methodgetListView()and then try to set your footer view before you set the adapter.