Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid two dimensional ArrayList empty after filling it
    primarykey
    data
    text
    <p>I have an OpenGL application, where I fill a two dimensional int List with data, I also Logging the size every time I put data in it. It works grate, there is 236 row. But after I call the method later in the Log it gives me back that the size is 0. Here is how the structur looks like:</p> <p>Main.java</p> <pre><code>... onDrawFrame(GL10 gl) { if (first == true) { // the data comes from another method myList.setData(x, y); // I send the the data for the List // and also log the List size, which at the end is 236 first = false; } myList.check(); // It just Logs the List size, which gives back 0 } ... </code></pre> <p>List.java</p> <pre><code>private List&lt;int[]&gt; dataS = new ArrayList&lt;int[]&gt;(); public void setData(int x, int y) { dataS.add(new int[] { x, y }); Log.i("size", "size: " + dataS.size()); } public void check() { Log.i("check", "check: " + dataS.size()); } </code></pre> <p>I just can't understand what is the problem with it, hope someone can help me.</p> <p><strong>Whole code:</strong></p> <p>Main.java</p> <pre><code>public class Main extends GLSurfaceView implements Renderer { public void drawGame(GL10 gl) { if (firstGameFrame == true) { tMap.setMap(); firstGameFrame = false; } collision.check(); } } </code></pre> <p>Map.java</p> <pre><code>public class Map { public void setMap() { // map1 is an int map1[][] = {{1,0,1}, {1,1,1}, {0,0,1}}; - of course there are more data in it for (int z = 0; z &lt; map1.length; z++) { for (int x = 0; x &lt; map1[z].length; x++) { if (map1[z][x] == 1) { collision.getWall((x*2) - 23, (z * 2) - 27); } } } } } </code></pre> <p>Collision.java</p> <pre><code>public class Collision { private List&lt;Integer[]&gt; wallCoord = new ArrayList&lt;Integer[]&gt;(); public void getWall(int x, int y) { wallCoord.add(new Integer[] { x, y }); Log.i("getwall", "getwall " + x + " " + y + " size " + wallCoord.size()); } public void check() { Log.i("coords", "size: " + wallCoord.size()); } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload