1

I want to represent a DataBase output to a GridView, the deal is that I want this GridView scroll horizontally and vertically. The reason for that is that I may have a table that has a number of columns that will not fit on screen, So Horizontal scrolling is necessary.

Now for vertical scrolling: I may have a big DataBase (with 100 entries and more...) So I do want it to scroll vertically as well and use the View recycling mechanism to populate the GridView (for the Vertical Scrolling, no View recycling is needed for the Horizontal Scrolling).

I have already stumbled on this solution: https://gist.github.com/codeswimmer/869685

But I have few problems with this:

1. It uses a deprecate Gallary View.

2. I think this changes the vertical scrolling to a horizontal one but doesn't allow both of them.

Is this even possible? Any direction on this topic would be really appreciated.

Emil Adz
  • 40,709
  • 36
  • 140
  • 187
  • possible duplicate of [Bidircetional scroll for Android](http://stackoverflow.com/questions/4674326/bidircetional-scroll-for-android) – Pankaj Kumar May 16 '13 at 09:20
  • did you tried with https://gist.github.com/codeswimmer/869685 – Pankaj Kumar May 16 '13 at 09:21
  • @PankajKumar Yes, this is the first result for this search in google. But I had no luck in using it. Have you tried this solution? – Emil Adz May 16 '13 at 09:32
  • @MuhammadBabar, this is the solution I corrently have. combined with a TableLayout. the problem with this is that when I have a lot of entries (and because there is no View recycling) then my activity takes a long a time (5-10 seconds) to show the table I want to show. – Emil Adz May 16 '13 at 10:52
  • @MuhammadBabar, I will say again: currently I use a Tablelayout that is placed inside a HorizontalScrollView that is placed inside a ScrollView. I want to change this implementation to a GridView (that is scrolled vertically by default) and add to it the ability to scroll horizontally to gain the usage of View's recycling in this activity. – Emil Adz May 16 '13 at 10:58
  • You should use `android:numColumns="auto_fit"` in `GridView`, so you won't need to scroll it horizontally, and i personally think its a bad idea to have a horizontall scrolling GridView. – Muhammad Babar May 16 '13 at 10:59
  • but what if the data I need to present takes more screen space then I have? – Emil Adz May 16 '13 at 11:00
  • `android:numColumns="auto_fit"` will do the trick, it only let the items to take space that is available, so you don't need to scroll horizontally – Muhammad Babar May 16 '13 at 11:04
  • what will happens to the columns that will not have enough space? – Emil Adz May 16 '13 at 11:06
  • You can define width for columns `android:columnWidth="85dp"`, you must try it first then you will get the answer yourself, e.g on a 320x420 device their will be most likely 3 items per row, but on a device 800x1280 it will show 4 items per row, as i told you before auto_fit will do the trick – Muhammad Babar May 16 '13 at 11:11
  • You are really missing the point. I have tables where I have 8-10 column. So 3-4 columns is not helpful to me. I need it to be scrollable horizontally. – Emil Adz May 16 '13 at 11:13
  • let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/30053/discussion-between-muhammad-babar-and-emil-adz) – Muhammad Babar May 16 '13 at 11:14

0 Answers0