ListView listView = findViewById(R.id.list_view); int itemCount = listView.getCount();
String[] fruits = {"Apple", "Banana", "Grapes", "Orange", "Pineapple"}; ArrayAdapterIn this example, we create an `ArrayAdapter` to populate the `ListView` with some fruit names. After setting the adapter to the `ListView`, we call the `getCount` method to get the number of items in the list. Package library: `android.widget` which is a part of the Android SDK.adapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, fruits); ListView listView = findViewById(R.id.list_view); listView.setAdapter(adapter); int itemCount = listView.getCount();