If I understand correctly, you want to display the contents of your arrayList in a Toast.
- Like donfuxx said, you need to create your arrayList outside of your onclicklistener.
- As the user clicks an item, it will be added to your arrayList.
Then loop over the list to fill a string called allItems, then show allItems in a toast.
ArrayList<String> checked = new ArrayList<String>(); listView.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { String listItem = (String) listView.getItemAtPosition(position); if(!checked.contains(listItem)){ //optional: avoids duplicate Strings in your list checked.add((position+1), listItem); } String allItems = ""; //used to display in the toast for(String str : checked){ allItems = allItems + "\n" + str; //adds a new line between items } Toast.makeText(getApplicationContext(),allItems, Toast.LENGTH_LONG).show(); } });