I am initializing a list view like below and setting its custom adapter
lvRecords = (ListView) findViewById(R.id.lv_records);
lvRecords.setAdapter(adapterSearchResult);
Below is my adapter
public class SearchResultListAdapter extends ArrayAdapter implements View.OnClickListener{
private Context context;
private ArrayList<Record> records;
private int numOfPaginatorBtns = 0;
static class HolderView {
public TextView tvBahiNum;
public TextView tvRegNum;
public TextView tvYear;
public Button btnDetails;
public Button btnRegistry;
}
@SuppressWarnings("unchecked")
public SearchResultListAdapter(Context c, ArrayList<Record> records, int numOfPaginatorBtns) {
super(c, R.layout.search_result_item, records);
this.context = c;
this.records = records;
this.numOfPaginatorBtns = numOfPaginatorBtns;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
Log.e("position", Integer.toString(position));
if (convertView == null) {
Log.e("in" , "convert View");
LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView = inflater.inflate(R.layout.search_result_item, parent, false);
HolderView listItem = new HolderView();
listItem.tvBahiNum = (TextView) convertView.findViewById(R.id.tv_bahi_num);
listItem.tvRegNum = (TextView) convertView.findViewById(R.id.tv_reg_num);
listItem.tvYear = (TextView) convertView.findViewById(R.id.tv_year);
listItem.btnDetails = (Button) convertView.findViewById(R.id.btn_details);
listItem.btnDetails.setOnClickListener(this);
convertView.setTag(listItem);`}`
HolderView listItem = (HolderView) convertView.getTag();
Record rec = records.get(position);
listItem.tvRegNum.setText(rec.regNum);
listItem.tvBahiNum.setText(rec.bahiNum);
listItem.tvYear.setText(rec.year);
return convertView;
}
@Override
public void onClick(View view) {
switch (view.getId()){
case R.id.btn_details:
break;
}
}
}
I want to check how many times my getView is called for the first view of my list View (lvRecords). Basically i want to track number of visible list items.
Any help? Thanks!!