The android.widget.ListView is a view that displays a list of items. The getCheckedItemPosition() method is used to get the position of the checked item in the list view.
Example 1: Suppose we have a ListView with a checkbox for each item. When the user clicks on the checkbox, we want to get the position of the checked item. We can use the following code:
ListView listView = findViewById(R.id.list_view); int position = listView.getCheckedItemPosition();
Example 2: Suppose we want to get the position of the first checked item in the ListView. We can use the following code:
ListView listView = findViewById(R.id.list_view); int position = listView.getCheckedItemPosition();
if (position != ListView.INVALID_POSITION) { // Do something with the checked item at position }
The package library for the android.widget.ListView is android.widget.
Java ListView.getCheckedItemPosition - 17 examples found. These are the top rated real world Java examples of android.widget.ListView.getCheckedItemPosition extracted from open source projects. You can rate examples to help us improve the quality of examples.