2017-04-11 1 views
0

ich gegoogelt, aber immer noch nicht Lösung für mich gefunden hat.Databinding Fehler - konnte nicht gefunden werden Accessor

Das ist mein xml:

<?xml version="1.0" encoding="utf-8"?> 
<layout xmlns:app="http://schemas.android.com/apk/res-auto" 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools"> 

    <data> 
     <import 
      alias="noteViewModel" 
      type="com.app.screen.createnote.CreateNoteViewModel" /> 
    </data> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:orientation="vertical"> 

     <EditText 
       android:id="@+id/etNote" 
       style="@style/JWidget.EditText.Grey" 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       android:gravity="start" 
       android:inputType="textMultiLine" 
       android:scrollbars="vertical" 
       android:text="@={noteViewModel.note.description}" />   
    </LinearLayout> 
</layout> 

Das ist mein Ansichtsmodell Code:

public class CreateNoteViewModel extends BaseObservable { 
    private Note note; 
    @Bindable 
    public Note getNote() { 
     return note; 
    } 

    public void setNote(Note note) { 
     this.note = note; 
     notifyPropertyChanged(BR.note); 
    } 

}

Aber wenn ich meine app laufen versuche ich bekam es:

Error:Execution failed for task ':app:compileDebugJavaWithJavac'. 

java.lang.RuntimeException: Datenverbindungsfehler gefunden. ****/Datenbindungsfehler **** msg: Konnte nicht finden Accessor com.justsafe.tmgr.justsafe.screen.createnote.CreateNoteViewModel.note Datei: C: \ android \ work \ JustSafeTmgr \ app \ src \ Haupt \ res \ layout \ activity_create_note.xml loc: 44: 33 - 44:62 **** \ data Bindungsfehler ****

PS An anderer Stelle in meiner App funktioniert es, aber da bekomme ich Probleme.

Antwort

2

Versuchen Sie, die <import> Tag zu einem <variable> Tag zu ändern:

<data> 
     <variable 
      name="noteViewModel" 
      type="com.app.screen.createnote.CreateNoteViewModel" /> 
    </data> 
+0

Thank you very very-much! – Artem

+0

Sie sind willkommen: D Können Sie die Antwort akzeptieren? –

+0

Ja, tut mir leid, danke! – Artem

Verwandte Themen