@@ -117,12 +117,18 @@ export class DropDown extends DropDownBase {
117117 this . nativeView . onDetachedFromWindowX ( ) ;
118118 }
119119
120+ public refresh ( ) {
121+ this . _updateSelectedIndexOnItemsPropertyChanged ( this . items ) ;
122+ ( this . android . getAdapter ( ) as DropDownAdapter ) . notifyDataSetChanged ( ) ;
123+
124+ // Coerce selected index after we have set items to native view.
125+ selectedIndexProperty . coerce ( this ) ;
126+ }
127+
120128 public [ selectedIndexProperty . getDefault ] ( ) : number {
121129 return null ;
122130 }
123131 public [ selectedIndexProperty . setNative ] ( value : number ) {
124- this . _clearCache ( RealizedViewType . DropDownView ) ;
125-
126132 const actualIndex = ( types . isNullOrUndefined ( value ) ? 0 : value + 1 ) ;
127133 this . nativeView . setSelection ( actualIndex ) ;
128134 }
@@ -195,6 +201,16 @@ export class DropDown extends DropDownBase {
195201 return this . _realizedItems [ realizedViewType ] . get ( convertView ) ;
196202 }
197203
204+ public _clearCache ( realizedViewType : RealizedViewType ) {
205+ const realizedItems = this . _realizedItems [ realizedViewType ] ;
206+ realizedItems . forEach ( ( view ) => {
207+ if ( view . parent ) {
208+ view . parent . _removeView ( view ) ;
209+ }
210+ } ) ;
211+ realizedItems . clear ( ) ;
212+ }
213+
198214 private _propagateStylePropertyToRealizedViews ( property : string , value : any , isIncludeHintIn = true ) {
199215 const realizedItems = this . _realizedItems ;
200216 for ( const item of realizedItems ) {
@@ -224,16 +240,6 @@ export class DropDown extends DropDownBase {
224240 this . selectedIndex = null ;
225241 }
226242 }
227-
228- private _clearCache ( realizedViewType : RealizedViewType ) {
229- const realizedItems = this . _realizedItems [ realizedViewType ] ;
230- realizedItems . forEach ( ( view ) => {
231- if ( view . parent ) {
232- view . parent . _removeView ( view ) ;
233- }
234- } ) ;
235- realizedItems . clear ( ) ;
236- }
237243}
238244
239245/* A snapshot-friendly, lazy-loaded class for TNSSpinner BEGIN */
@@ -285,6 +291,8 @@ function initializeTNSSpinner() {
285291 eventName : DropDownBase . closedEvent ,
286292 object : owner
287293 } ) ;
294+
295+ owner . _clearCache ( RealizedViewType . DropDownView ) ;
288296 }
289297 }
290298
0 commit comments