@@ -33,9 +33,14 @@ class DetailedList(Widget):
33
33
def create (self ):
34
34
# DetailedList is not a specific widget on Android, so we build it out
35
35
# of a few pieces.
36
- parent = android_widgets .LinearLayout (self ._native_activity )
37
- parent .setOrientation (android_widgets .LinearLayout .VERTICAL )
38
- self .native = parent
36
+
37
+ if self .native is None :
38
+ self .native = android_widgets .LinearLayout (self ._native_activity )
39
+ self .native .setOrientation (android_widgets .LinearLayout .VERTICAL )
40
+ else :
41
+ # If create() is called a second time, clear the widget and regenerate it.
42
+ self .native .removeAllViews ()
43
+
39
44
scroll_view = android_widgets .ScrollView (self ._native_activity )
40
45
scroll_view_layout_params = android_widgets .LinearLayout__LayoutParams (
41
46
android_widgets .LinearLayout__LayoutParams .MATCH_PARENT ,
@@ -47,7 +52,7 @@ def create(self):
47
52
self ._android_swipe_refresh_layout = android_widgets .SwipeRefreshLayout (
48
53
__jni__ = java .NewGlobalRef (swipe_refresh_wrapper ))
49
54
swipe_refresh_wrapper .addView (scroll_view )
50
- parent .addView (swipe_refresh_wrapper , scroll_view_layout_params )
55
+ self . native .addView (swipe_refresh_wrapper , scroll_view_layout_params )
51
56
dismissable_container = android_widgets .LinearLayout (self ._native_activity )
52
57
dismissable_container .setOrientation (android_widgets .LinearLayout .VERTICAL )
53
58
dismissable_container_params = android_widgets .LinearLayout__LayoutParams (
@@ -70,9 +75,9 @@ def _make_row(self, container, i):
70
75
# Add user-provided icon to layout.
71
76
icon_image_view = android_widgets .ImageView (self ._native_activity )
72
77
icon = self .interface .data [i ].icon
73
- icon . bind ( self . interface . factory )
74
- bitmap = android_widgets . BitmapFactory . decodeFile ( str ( icon . _impl . path ) )
75
- if bitmap is not None :
78
+ if icon is not None :
79
+ icon . bind ( self . interface . factory )
80
+ bitmap = android_widgets . BitmapFactory . decodeFile ( str ( icon . _impl . path ))
76
81
icon_image_view .setImageBitmap (bitmap )
77
82
icon_layout_params = android_widgets .RelativeLayout__LayoutParams (
78
83
android_widgets .RelativeLayout__LayoutParams .WRAP_CONTENT ,
0 commit comments