Android 2d array and ArrayAdapter GrideVidew

  • Replies:1
  • OpenNot stickiedUnanswered
  • Forum posts: 2

Sep 4, 2014 5:17:00 PM via Website

Hello, I want to use 2-d Array in GrideView I tried a lot but it is not giving me desired output. Here is my code.

public class MainActivity extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    GridView lv = (GridView) findViewById(R.id.mylistview);

    int s[][] = new int[2][2];
    /*
     * String s[][] = new String[8][8]; for(int i=0;i<=7;i++) for(int j = 0;
     * j <= 7; j++){ s[i][j]="9"; }
     */
    for (int y = 0; y <= 1; y++)
        for (int u = 0; u <= 1; u++)
            s[y][u] = 6;
    ArrayAdapter a = new ArrayAdapter(this, R.layout.rowlb, R.id.textview1,
            s);
    lv.setAdapter(a);

}
}