1

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 ) ?

1 Answer 1

3

Gridview.xml

<GridView 
        android:id="@+id/GridView01" 
        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">
    </GridView>

GridView.java

gv = (GridView) findViewById(R.id.GridView01); 
gv.setAdapter(<your adapter of button names>);
gv.setOnItemClickListener(<listener for each item click>);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.