简体   繁体   English

如何在带有水平和垂直滚动条的android中显示表格等电子表格

[英]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. 我找到了这个博客,其中Matt Clark创建了一个新的TwoDScrollView类。

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

PsuedoCode 伪代码

Have a TableLayout inside a scrollview!!! 在滚动视图中有一个TableLayout !!!

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. 而且,如果您仍然无法获得它,请把我的整个课程上传到GitHub。

Create a ScrollView and then inside of this place a HorizontalScrollView. 创建一个ScrollView,然后在此内部放置一个Horizo​​ntalScrollView。 Now this will behave as on object that has both Vertical and Horizontal Scrolling properties. 现在,这将像具有“垂直”和“水平”滚动属性的对象一样。

I know GridView is not popular for your purpose. 我知道GridView并不受欢迎。 But it still gives us an easier way to build spreadsheet like UI. 但这仍然为我们提供了一种构建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. 如您所说,GridView本身不是水平滚动的,并且如果gridview中的控件数量超过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. 但是我认为您想要尝试的是固定将显示给定矩形数据区域的gridview的大小,并覆盖其touch事件以模拟滚动操作。 Thanks to base adapter and other techniques for gridview, your work will be minimal. 多亏了基本适配器和用于gridview的其他技术,您的工作量才最小。

Good example of such a method is Dennis's work 丹尼斯的工作就是这种方法的一个很好的例子。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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