0

I want a 7x4 table backed by an adapter that never scrolls, but rather will fit to take up its available space, sizing each cell in a uniform way. I want it backed by an adapter because it has built-in functionality for taking care of data set changes and recycling views. Here's a few things I've considered:

  • Extending AbsListView and implementing it myself
  • Extending TableLayout and giving it fields to pass in an adapter

Both seem cumbersome. I was wondering if people could see the light at the end of the tunnel, or know of any 3rd party libraries that already have what I'm seeking.

Jason Robinson
  • 31,005
  • 19
  • 77
  • 131

1 Answers1

0

Try using a GridView.

<GridView android:id="@+id/yourgridview"
    android:alwaysDrawnWithCache="true"
    android:drawSelectorOnTop="false"
    android:columnWidth="78dp"
    android:numColumns="7"
    android:stretchMode="spacingWidth"
    android:layout_height="match_parent"
    android:layout_width="match_parent"
    android:stackFromBottom="false" />

Then use java to set the adapter to the GridView. Hope I helped.

user1779764
  • 91
  • 2
  • 5
  • That's what I'm using now. The problem is that `GridView` will scroll its content if it can't fit everything on the screen. I want it to fit on the screen without scrolling, resizing the children views if necessary. – Jason Robinson Oct 27 '12 at 19:48
  • Then you have to get the screen width and height, set the column width and item height as a % of the screen overall size. To get screen dimensions : Display display = getWindowManager().getDefaultDisplay(); Point size = new Point(); display.getSize(size); int width = size.x; int height = size.y; – user1779764 Oct 27 '12 at 21:01
  • I may end up having to do that, but it'd be based off the parent `ViewGroup` since it doesn't it doesn't take up the whole screen. – Jason Robinson Oct 27 '12 at 21:22
  • Then use `GridView gv = (GridView)findViewById(R.id.yourgridview); int width = gv.getWidth(); int height = gv.getHeight();` to get the GridView's size. – user1779764 Oct 27 '12 at 21:28
  • The size of the `GridView` isn't the problem. The problem is that once that size is exceeded, it will become scrollable. – Jason Robinson Oct 27 '12 at 22:19
  • `android:overScrollMode="never"` – user1779764 Oct 28 '12 at 15:07