具有原生 Android 滚动条的数据网格卡住或不显示整个列表
Data Grid with native Android scroller gets stuck or does not show the whole list
我将数据网格与本机 Android 滚动条一起使用,代码如下。
当仅将它用于数据网格中的一个视图时,它工作正常。但是当在不同视图之间切换时,DG 的滚动不再起作用 - 它卡住或不显示整个列表 - 请参阅文档中的完整描述和屏幕截图 here
另见 stack.
我必须更改代码中的哪些内容以及在哪里才能使其正常工作?
local sScrollerID,isScrolling
on openCard
## Create scroller now:
create_scroller
pass openCard -- added just to see if it helps; it does not
end openCard
on closecard
delete_scroller
pass closeCard -- added just to see if it helps; it does not
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 natove object when card closes!!!!!
command delete_scroller
if the environment <> "mobile" then
exit delete_scroller
end if
MobileControlDelete sScrollerID
end delete_scroller
我试图通过将局部变量更改为全局变量来解决它。然后,我在每个具有用于在数据网格中打开不同视图的脚本的按钮中将 empty 放入全局按钮中,但它不起作用。
好的,我明白了。
我添加了这一行:send "delete_scroller" to cd "main" in 0 sec
在每个处理程序中(在它的开头)在数据网格中创建新视图
而这个:send "create_scroller" to cd "main" in 0 sec
在它末尾的同一个处理程序中。
换句话说,每次用新数据更新数据网格时,我都必须删除和创建滚动条。
我将数据网格与本机 Android 滚动条一起使用,代码如下。 当仅将它用于数据网格中的一个视图时,它工作正常。但是当在不同视图之间切换时,DG 的滚动不再起作用 - 它卡住或不显示整个列表 - 请参阅文档中的完整描述和屏幕截图 here 另见 stack.
我必须更改代码中的哪些内容以及在哪里才能使其正常工作?
local sScrollerID,isScrolling
on openCard
## Create scroller now:
create_scroller
pass openCard -- added just to see if it helps; it does not
end openCard
on closecard
delete_scroller
pass closeCard -- added just to see if it helps; it does not
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 natove object when card closes!!!!!
command delete_scroller
if the environment <> "mobile" then
exit delete_scroller
end if
MobileControlDelete sScrollerID
end delete_scroller
我试图通过将局部变量更改为全局变量来解决它。然后,我在每个具有用于在数据网格中打开不同视图的脚本的按钮中将 empty 放入全局按钮中,但它不起作用。
好的,我明白了。
我添加了这一行:send "delete_scroller" to cd "main" in 0 sec
在每个处理程序中(在它的开头)在数据网格中创建新视图
而这个:send "create_scroller" to cd "main" in 0 sec
在它末尾的同一个处理程序中。
换句话说,每次用新数据更新数据网格时,我都必须删除和创建滚动条。