简体   繁体   中英

how to display spreadsheet like table in android with horizontal and vertical scrollbars

我想用水平和垂直滚动条在android屏幕上显示Excel工作表..plz帮助我.net上我搜索了很多

There are base classes for horizontal scroll views and vertical scrollviews, but not one where one can scroll in two dimensions at the same time.

I have found this blog in which Matt Clark have created a new TwoDScrollView class.

http://blog.gorges.us/2010/06/android-two-dimensional-scrollview/

PsuedoCode

Have a TableLayout inside a scrollview!!!

How to populate it->

For each row in spreadsheet TableRow tr = new TableRow() For each cell in row //Create a textview.// TextView trCell = new TextView() //Set TextView text, get text from spreadsheet current cell.// trCell.setText(cell.textvalue) tr.addview(trCell) } tableLayout.addView(tr) //Add tablerow to the tablelayout.// }

Since table is in a scrollview, if table rows extend length of scroll view, scrollbars will appear.

If you need more info, I'll post my exact code. And if you still cant get it, ill upload my whole class to GitHub.

Create a ScrollView and then inside of this place a HorizontalScrollView. Now this will behave as on object that has both Vertical and Horizontal Scrolling properties.

I know GridView is not popular for your purpose. But it still gives us an easier way to build spreadsheet like UI.

As you said, GridView itself is not horizontally scrollable and will be extremely slow if number of controls in the gridview exceeds says 500.

But I think what you want to try is to fix size of the gridview that will display given rectangle area of data and to override its touch event to emulate scrolling actions. Thanks to base adapter and other techniques for gridview, your work will be minimal.

Good example of such a method is Dennis's work

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM