Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
430 views
in Technique[技术] by (71.8m points)

android - PartialTextChanged stops firing on MvxAutoCompleteTextView after Item selection

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 onoff 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 mondroidxamarin android code?

Thanks

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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 signalledset 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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...