TAGS :Viewed: 5 - Published at: a few seconds ago

[ Create matrix of buttons using GridView ]

Can anybody help me to make matrix of buttons in code using GridView. I tried with TableLayout but it doesn't look like GridLayout in Java ( cannot to add space between buttons in same row ) ?

Answer 1


        android:layout_width="fill_parent" android:layout_height="fill_parent" android:columnWidth="90dp" android:numColumns="auto_fit" android:verticalSpacing="10dp" android:horizontalSpacing="10dp" android:stretchMode="columnWidth" android:gravity="center">


gv = (GridView) findViewById(R.id.GridView01); 
gv.setAdapter(<your adapter of button names>);
gv.setOnItemClickListener(<listener for each item click>);