mercredi 28 août 2019

How to generate random list and insert into listview

I am trying to put random items from an array and insert them into a listview, at the moment the listview is just coming up blank. Ideally I would like to be able to retrieve what position from the array the list item is if it is clicked on too

String[] levelOneListList = new String[] { "Daisy", "Rock", "Tree", "Dandelion", "Grass" };

Random r=new Random(); int randomNumber=r.nextInt(levelOneListList.length);

    ArrayAdapter arrayAdapter = new ArrayAdapter(this, android.R.layout.simple_list_item_checked, randomNumber);

The listview is now empty on the emulator




Aucun commentaire:

Enregistrer un commentaire