Auto-complete MVVM and Java Castings without using Java.Lang.Object in ViewModel

I have a problem with castings. First I will give an example of how to make a custom adapter for autocomplete without MVVM in Monodroid: https://github.com/BitStab/Monodroid-Custom-Auto-Complete/blob/master/MonoAndroidApplication1/CustomerAdapter.cs

Now I will try this in MVVMCross, but for this I will have to extend my ViewModel with Java.Lang.Object. This will ruin its portability. I'm looking for a workaround right now, and I'm not an mvvm expert, I need help.

I started creating new classes in mvvmCross Bindigs, as you can find here: https://github.com/BitStab/MvvmCross/tree/master/Cirrious/Cirrious.MvvmCross.Binding/Android/Views

I am trying to make this as general as possible, but I need a method to translate from my personal C # object to Java.Lang.Object. Is there a way to do this without expanding my ViewModel? If anyone has another idea, I would be happy to get inspiration!

Thanks for the help!

+2
source share
1 answer

If you need portable code, then you certainly do not want Java.anything anywhere near your ViewModels projects.

, CustomerAdapter - . , Java, - , , , AutoCompleteTextView - ​​ (IMHO).

API Google , - . :

OneTwoThree

Autocomplete - ​​ MvvmCross. , , - .

3 :

  • PartialText - , ViewModel
  • ItemsSource - , PartialText - ViewModel
  • SelectedObject - - ViewModel

xml :

<Mvx.MvxBindableAutoCompleteTextView
  android:layout_width="fill_parent"
  android:layout_height="wrap_content"
  local:MvxItemTemplate="@layout/listitem_book"
  local:MvxBind="{'Text':{'Path':'EnteredText','Mode':'TwoWay'},
  'ItemsSource':{'Path':'AutoCompleteSuggestions'},
  'PartialText':{'Path':'CurrentTextHint'},
  'SelectedObject':{'Path':'CurrentBook'}}"
    />

, - Android , PartialText ItemsSource - , .

: https://github.com/slodge/MvvmCross/tree/master/Sample%20-%20SimpleDialogBinding/SimpleBinding/DroidAutoComplete

, " ", Mvx, ViewModel .

- , :


- , , , Android !

+2

Source: https://habr.com/ru/post/1537660/


All Articles