How to pass the parameter on the position number, element listview, to the mass



  • Injection listview We need to transfer the position to the mass without additional cycles.

        public class TicketActivity extends Activity {
    //...
    for (int n = 0; n < 20; n++) {
        int[] arrayAnswer = new int[20];
        //...    
        ArrayAdapter < String > adapter1 = new ArrayAdapter < String > (this, android.R.layout.simple_list_item_1, listNumber1);
        listAnswers.setAdapter(adapter1);
        listAnswers.setOnItemClickListener(new AdapterView.OnItemClickListener() {@
            Override
            public void onItemClick(AdapterView <? > parent, View v, int position, long id) {
                //нужно при каждом проходе цикла запихнуть значение position в массив arrayAnswer 
            }
        });
    


  • Do it. arrayAnswer and write it out. onItemClick()

    I don't understand any more of your code, unfortunately.




Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2