Count Total Number of List Items in a ListView
android, listview
Solution
Total list view count is
lstView.getAdapter().getCount() ,
So use
Toast.makeText(getApplicationContext(), "Total number of Items are:" + lstView.getAdapter().getCount() , Toast.LENGTH_LONG).show();
Problem
How to count Total Number of List Items in a ListView ? I am writing a Church Application in which i am populating list using images stored into SD Card, but now i want to count total number of list items. ``` // to upload whole list for(int position = 0; position < lstView.getAdapter().getCount(); position++) { flags.put(position, true); } ((BaseAdapter) lstView.getAdapter()).notifyDataSetChanged(); } }); /*** Get Images from SDCard ***/ listSDCardImages = fetchSDCardImages(); // ListView and imageAdapter lstView = (ListView) findViewById(R.id.listSDCardImages); lstView.setAdapter(new ListSDCardImagesAdapter(this)); Toast.makeText(getApplicationContext(), "Total number of Items are:" + String.valueOf(position), Toast.LENGTH_LONG).show(); } ``` Everytime i am getting 0