用于数据网格的原生Android滚动条

时间:2014-04-08 16:39:02

标签: livecode

我使用下面的代码用于数据网格的原生Adroid卷轴,它几乎可以正常工作。几乎,因为在我的堆栈中的一个特定视图中,它似乎是不可靠的。下载堆栈并检查以下内容:来回浏览3-4次"我的类别"和#34;我的选择"然后在某些时候滚动不适用于"我的类别"视图。然后我必须重新启动应用程序,它运行正常。 你认为它取决于什么? 代码是:

    on openCard

      local tScrollerRect, tContentRect

   // Only create a scroller on a mobile device
   if environment() is not "mobile" then exit openCard

   // Set the area of the scroller
   put the rect of group "DataGrid 1" into tScrollerRect

   // Set the area of the content to be scrolled
  put 0,0,(the DGformattedWidth of group "DataGrid 1"),(the DGformattedHeight of group "DataGrid 1") into tContentRect

   // Create the scroller control
   mobileControlCreate "scroller", "loremScroll"
   put the result into sScrollerID

   // Set the properties of the scroller
   mobileControlSet "loremScroll", "rect", tScrollerRect
   mobileControlSet "loremScroll", "contentRect", tContentRect
   mobileControlSet "loremScroll", "visible", true
   mobileControlSet "loremScroll", "scrollingEnabled", true
   mobileControlSet "loremScroll", "vIndicator", true
   mobileControlSet "loremScroll", "vscroll", 0

end openCard


on closeCard
   // Delete the scroller
   if environment() is not "mobile" then exit closeCard
   mobileControlDelete sScrollerID
 end closeCard

on scrollerDidScroll hOffset, vOffset
   // When the user scrolls move the displayed content
   set the DGvScroll of group "DataGrid 1" to vOffset
end scrollerDidScroll

您可以下载堆栈here

1 个答案:

答案 0 :(得分:0)

我下载并安装了你的堆栈。如果我只是滚动,似乎一切正常。如果我点击我的类别,它不会滚动,可能是因为contentRect不正确。如果我单击“我的选择”,则数据网格为空,显然滚动无法正常工作。

我建议你执行

put 0,0,(the DGformattedWidth of group "DataGrid 1"),(the DGformattedHeight of group "DataGrid 1") into tContentRect
mobileControlSet "loremScroll", "contentRect", tContentRect

每次“所有类别”,“我的选择”或“我的类别”按钮之一的脚本都会运行。