我希望将Android原生卷轴用于显示大约700条记录的数据网格。下面的滚动条代码位于其上有数据网格的卡片中。卡片脚本是:
on openCard
dispatch "ResetList" to group "DataGrid 1"
if text of fld "view" of cd "main" is "Favourites" then
send "mouseUp" to btn "favourites" of cd "home"
end if
RefreshAllLines
local sScrollerID,isScrolling
## Create scroller now:
create_scroller
end openCard
on closecard
delete_scroller
end closecard
command create_scroller
put "DataGrid 1" into tScrollerGroup
if the environment <> "mobile" then
exit create_scroller
end if
## Create native scroller object and save its ID in a local variable
MobileControlCreate "scroller"
put the result into sScrollerId
## RECT is the area on the card where the SCOLLER should do its work
MobileControlSet sScrollerId, "rect", (the rect of grp tScrollerGroup)
put the width of grp tScrollerGroup into tWidth
put the dgFormattedheight of grp tScrollerGroup into tHeight
set the dgvScroll of grp tScrollerGroup to 0
## WHAT part fo the datagrid shall be scrolled-> the complete datagrid
MobileControlSet sScrollerId, "contentRect", (0,0,tWidth,tHeight)
## Display SCROLLER
MobileControlSet sScrollerId, "visible", "true"
## the typical BUMP effect when you ge to the edge of the object
MobileControlSet sScrollerId, "canBounce", "true"
MobileControlSet sScrollerId, "pagingEnabled", "false"
MobileControlSet sScrollerId, "vIndicator", "false"
MobileControlSet sScrollerId, "borderStyle", "none"
MobileControlSet sScrollerId, "canScrollToTop", "false"
end create_scroller
## Will be sent when the user actually SCROLLs with his finger
on scrollerDidScroll OffsetX, OffsetY
lock screen
put true into isScrolling
set the dgvScroll of grp "DataGrid 1" to OffsetY
unlock screen
end scrollerDidScroll
## REMOVE native object when card closes!
command delete_scroller
if the environment <> "mobile" then
exit delete_scroller
end if
MobileControlDelete sScrollerId
end delete_scroller
--local isScrolling
on mouseUp
if not isScrolling then
send mouseUp to field "Label" of group "Row Template 0003" \
of group "dgList" of group "dgListMask" of group "DataGrid 1" of card "main"
end if
end mouseUp
on mouseDown
put false into isScrolling
end mouseDown
当用于文本字段时,代码非常有效,但当用于数据网格时,滚动速度缓慢且缓慢。
是由于代码还是数据网格的固有功能?
如何提高滚动的响应速度和速度?
我的堆栈的链接是:DG-only-1.16.zip 要测试独立的数据网格,请单击&#34;选择全部&#34;,然后&#34;行&#34;然后&#34;整个选择&#34;
我在卡上添加了2个带有数据网格的按钮,用于测试目的。上面的一个是将DG的layerMode切换为滚动/静态,而下面的一个是切换堆栈的acceleratedRendering On / Off。
令人惊讶的是,我注意到,在escaRendering关闭且DG的layerMode设置为滚动并且加速渲染打开时稍微缓慢的情况下,滚动效果稍好一些! 添加了按钮的新堆栈的链接是:DG-only-1.16+accelRend.zip
按钮代码:
on mouseUp
## Switch layerMode
if the label of me is "Off" then
set the label of me to "On"
set the layerMode of group "DataGrid 1" to "scrolling"
else
set the label of me to "Off"
set the layerMode of group "DataGrid 1" to "static"
end if
end mouseUp
和
on mouseUp
## Switch acceleratedRendering on and off
if the label of me is "Off" then
set the label of me to "On"
set the acceleratedRendering of this stack to true
else
set the label of me to "Off"
set the acceleratedRendering of this stack to false
end if
end mouseUp
答案 0 :(得分:1)
我没有做任何Android开发,所以我无法测试。突出的一件事是scrollerDidScroll中的锁定屏幕。我曾经看过锁定屏幕调用之前经常调用很慢的事情。您可以尝试在scrollerDidScroll中删除锁定屏幕调用,并告诉我这是否可以提高性能吗?
您也可以尝试将数据网格组layerMode更改为“滚动”。
如果其中任何一项提高了效果,请告诉我。