2017-04-11 5 views
0

私はグーグルではありましたが、解決策はまだ見つかりませんでした。データバインドエラー - アクセサを見つけることができませんでした

これは私の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> 

これは私のViewModelコードです:

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); 
    } 

}

しかし、私は私のアプリを実行しようとすると、私はそれを得た:

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

java.lang.RuntimeException:データバインディングエラーが見つかりました。 **** /データバインディングエラー****:アクセサーを見つけることができませんでしたcom.justsafe.tmgr.justsafe.screen.createnote.CreateNoteViewModel.note ファイル:C:\ android \ work \ JustSafeTmgr \ app \ src \メイン\ RES \レイアウト\ activity_create_note.xml LOC:44:33 - 44:62 **** \データバインディングエラー****

PS私のアプリの別の場所では動作しますが、問題が発生します。

答えて

2

<variable>タグに<import>タグを変更してください:

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

は非常に、ありがとうございました! – Artem

+0

あなたは歓迎です:D答えを受け入れることができますか? –

+0

はい、申し訳ありません、ありがとうございます! – Artem