I have an android application that, in a loop from a json line, takes the necessary data and stuffs it into a variable. After that, you need to fill the ListView array of these variables. I fill the array in the same loop, and after it is completed, I create an adapter and assign it to my ListView . But nothing comes out ... Here is the code:

 JSONArray jsonarray = new JSONArray(jj); String[] val = new String[20]; //Π½Π΅ΠΎΠ±Ρ…ΠΎΠ΄ΠΈΠΌΡ‹ΠΉ ΠΌΠ½Π΅ массив int i; //Π‘Π°ΠΌ Ρ†ΠΈΠΊΠ»: for (i = 0; i < jsonarray.length(); i++) { JSONObject obj = jsonarray.getJSONObject(i); String lesson = obj.getString("lesson"); String task = obj.getString("task"); //Π’ΠΎΡ‚ моя пСрСмСнная "data" String data = lesson + ": " + task; //ΠšΠΎΡ‚ΠΎΡ€ΡƒΡŽ я Π·Π°ΠΏΠΈΡ…ΠΈΠ²Π°ΡŽ Π² массив Π² соотвСтствии с порядком (счСтчик i) val[i] = data; } //И дальшС Π΄Π΅Π»Π°Π΅ΠΌ Π°Π΄Π°ΠΏΡ‚Π΅Ρ€ ΠΈ Π² listView Π΅Π³ΠΎ: ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, mass); lv.setAdapter(adapter); //lv - listView 

ListView initialized, checked - everything is fine ... Help please who than can ..

  • one
    Well, of course it does not work. You pass your array to the list. And then you have in the code an array of val and in lv you pass mass - ArchDemon
  • @ArchDemon, Um, sorry. No, no, there is a typo. There val is transmitted .. - Egor
  • And what in this case is this ? - post_zeew
  • By "nothing goes" what do you mean? Sheet view does not display anything? Displays something wrong? Express yourself more specifically. And I understand the description of the array, the loop and the transfer of the array to the adapter in your different methods? In which? - xkor

0