// Get the ListView ListView listView = findViewById(R.id.list_view); // Get the item at position 0 Object item = listView.getItemAtPosition(0);
// Get the RecyclerView RecyclerView recyclerView = findViewById(R.id.recycler_view); // Get the item at position 1 Object item = recyclerView.getItemAtPosition(1);In this example, we get the RecyclerView by finding its ID in the layout file. We then call getItemAtPosition with position 1 to get the second item in the list. The package library in this example is androidx.recyclerview.widget, not android.widget, because we are using a RecyclerView instead of a ListView.