android - how to get columncount in gridview -
how column count in gridview when gridview noofcolumn="autofit" mode
how single row no of column
<gridview android:id="@+id/gridview" android:layout_width="fill_parent" android:layout_height="match_parent" android:background="@android:color/white" android:gravity="center" android:numcolumns="auto_fit" android:stretchmode="columnwidth" />
you can column count in java code..
gridview mgridview = (gridview)findviewbyid(r.id.gridview); int column_coutnt = mgridview.getnumcolumns();
second way:
int columns = 0; int children = mgridview.getchildcount(); if (children > 0) { int width = mgridview.getchildat(0).getmeasuredwidth(); if (width > 0) { columns = mgridview.getwidth() / width; } }
Comments
Post a Comment