0

With the following code I get some unexpected output:

Log.i(TAG, "Activity numColumns: "+mGrid.getNumColumns());
Log.i(TAG, "Activity verticalSpace: "+mGrid.getVerticalSpacing());
Log.i(TAG, "Activity horizontalSpace: "+mGrid.getHorizontalSpacing());

The log output says:

09-17 10:39:26.083: I/MeMoGame(744):Activity numColumns: -1
09-17 10:39:26.083: I/MeMoGame(744):Activity verticalSpace: 7
09-17 10:39:26.083: I/MeMoGame(744): Activity horizontalSpace: 0

Which is totally weird because these are entered values in XML:

    <GridView
    android:id="@+id/gridView"
    android:horizontalSpacing="@dimen/grid_horizontal_space"
    android:verticalSpacing="@dimen/grid_vertical_space"
    android:numColumns="4"

and:

    <dimen
    name="grid_horizontal_space">7dp</dimen>
    <dimen
    name="grid_vertical_space">7dp</dimen>

It looks like Android has begun some kind of lottery; or is there a reasonable explanation?

Szymon
  • 42,577
  • 16
  • 96
  • 114
PageMaker
  • 395
  • 1
  • 3
  • 10

0 Answers0