1

I am building an android UI for spreadsheet (for creating, editing, sorting, etc of nxm array of cells). I am wondering which one of these views (GridView or ListView) I should use?

Some specific requirements:

1) At least 100 rows and 100 columns

2) User interface needs to be fast

3) Ability to set row and column headers

4) Ability to sort columns

5) Ability to filter columns

5) Reordering rows and columns

There has been a similar question, but the answer is not clear

Need to create spreadsheet like control, what should I extend ListView or GridView?

Community
  • 1
  • 1
user3268403
  • 203
  • 2
  • 14

2 Answers2

0

It depends, of course. If you need "infinite" scrolling in both axes, then you (may) want to think about a GridView. (But if you really need arbitrary number of columns, you have a bigger problem.)

I would recommend a ListView, as the elements within it are re-used during vertical scrolling, which is a more likely model (many more rows than columns).

The row elements themselves can be 1-row grids, or some other more suitable container.

John Visosky
  • 237
  • 1
  • 1
  • John I have updated my question with some requirements. I do need scrolling in both axes. It would be great if it is both infinite and fast, but I will be satisfied with a 100X100 array. Does the number of rows and columns need to be equal in a gridView? If that's the case then gridview will be restrictive for me. You are right I expect more rows than columns. If I use listView, I will be able to scroll in both axes, right? – user3268403 Feb 07 '14 at 15:20
  • What I meant by the "infinite" scrolling is that ListView is designed to use an adapter to fill its items, and the items are re-used as they scroll out of view and new ones are needed at the other end. It's designed for "many rows" situations. You could also look at: http://stackoverflow.com/questions/2044775/scrollview-vertical-and-horizontal-in-android/6235806#6235806 – John Visosky Feb 07 '14 at 17:10
0

I probably wouldn't use either of them. Depending on your more specific requirements, you may spend a lot of time trying to get GridView or ListView to do exactly what you want. It may be easier to just roll your own solution by subclassing ViewGroup.

Check out android-times-square from the guys at Square for an example of a grid based ViewGroup subclass. Take a look at CalendarGridView and CalendarRowView in particular. That should give you a good potential starting point for the ViewGroup route.

Tyler MacDonell
  • 2,609
  • 18
  • 27
  • Tyler, thanks for the response. I will check-out the code and get back to you. However I did want to give more specific details about my requirements. I have edited my original question. – user3268403 Feb 07 '14 at 15:15
  • Yeah, based on your more specific requirements, I myself would certainly just subclass `ViewGroup`. I think there's a reason `android-times-square` doesn't implement a `GridView` subclass - it's not very flexible on it's own. A `ViewGroup` subclass would give you much more control for _probably_ less effort. You will have total control over how the views are recycled, which might be important in achieving points #1 and #2. – Tyler MacDonell Feb 07 '14 at 19:41
  • Played with listview, gridview, etc. You are right - I think subclassing viewgroup will be easier – user3268403 Feb 11 '14 at 06:31