changeset 2805:ebe139dc16dd

Android: Interface Builder passes index 65535 to make sure we are packing to the end of a box, but that caused an out of bounds error while previewing on Android. So check if we are out of bounds and pass -1 instead.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Tue, 19 Jul 2022 16:57:39 +0000
parents deefe6f5d716
children d7b6e19e44d2
files android/DWindows.kt
diffstat 1 files changed, 6 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/android/DWindows.kt	Tue Jul 19 15:56:11 2022 +0000
+++ b/android/DWindows.kt	Tue Jul 19 16:57:39 2022 +0000
@@ -3561,7 +3561,12 @@
                     params.setMargins(pad, pad, pad, pad)
                 }
                 item.layoutParams = params
-                box.addView(item, index)
+                // If we are out of bounds, pass -1 to add to the end
+                if(index >= box.childCount) {
+                    box.addView(item, -1)
+                } else {
+                    box.addView(item, index)
+                }
                 boxUpdate(box)
             }
         }