Reputation: 37627
I need to declare this gridView programaticalle, all with java code:
<GridView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/gridview"
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"
/>
How can i do it? i am searching for code examples and checking the documentation but i can't find the way :S
Thanks
Upvotes: 1
Views: 3915
Reputation: 3520
Did you check documentation? Everything is in the gridview documentation. For example, the code equivalent to android:numColumns
is setNumColumns(int)
.
For things like id you'll need to go back to View docs. Width and height will be set with LayoutParams .
Upvotes: 5