PartialTextChanged stops firing on MvxAutoCompleteTextView after Item selection

拈花ヽ惹草 提交于 2019-11-28 01:05:53

问题


I am using MVVMCross's wrapper around the Xamarin Android AutoCompleteTextView.

I use the PartialTextChanged changed event to signal that I need to call the ViewModel, from the View, to get some more suggestions.

This works fine up to the point the user selects an item from the list. After that point no changes to the text will cause the PartialTextChanged event to fire. It is as if filtering is turned off once a selection has been made.

There is a SetText method on the AutoCompleteTextView that seems to turn filtering on\off but I am unsure of the best way to use that.

The TextChangedEvent still fires on the control as does AfterTextChanged just not PartialTextChanged and it is that which drives the updates.

I have debugged through the MVVMCross source and cannot see a solution. Any have any ideas?

Where can I browse them mondroid\xamarin android code?

Thanks


回答1:


After attaching the MVVMCross Source Code and debugging all the events I found that under certain circumstances I was not updating the ItemsSource after the PartialText property was being changed

The FilteringAdapter uses a ManualResetEvent around the change to PartialText and that is only signalled\set by the NotifyDataSetChanged method.

After finding this I also found that @slodge also mentions this in this answer, AutoComplete MVVM and Java Castings without using Java.Lang.Object on ViewModel. A constraint that until now had passed me by.

Note that because of the Android threading model it is essential that every change in PartialText is met by an eventual signalled change in ItemsSource - and this should be a single change in object collection rather than lots of small changes.

Thanks



来源:https://stackoverflow.com/questions/26543931/partialtextchanged-stops-firing-on-mvxautocompletetextview-after-item-selection

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!