여기 누군가가 왜 작동하지 않는지 그리고 어떻게 해결할 수 있는지 설명 할 수 있습니다. 위의 코드 조각이 작동하지 않는 XML보기 파일보기의 속성에 대한 데이터 바인딩 오류
<com.projet.Core.Views.ProfileInfoItemView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
app:setNumber='@{account.posts.intValue()}'
app:setTitle="Posts"/>
에서
발췌문. 그러나 내가 값을 하드 코딩하면 완벽하게 작동합니다.
attrs.xml이
<declare-styleable name="ProfileInfoTextView">
<attr name="setNumber" format="integer" />
<attr name="setTitle" format="string" />
</declare-styleable>
발췌문 계정 클래스 ProfileInfoTextView 클래스
private void initialize(Context context, AttributeSet attributeSet) {
mRoot = inflate(context, R.layout.custom_profile_info_textview_container,this);
mNumberTextView = (TextView) mRoot.findViewById(R.id.custom_profile_info_number_text_view);
mTitleTextView = (TextView) mRoot.findViewById(R.id.custom_profile_info_title_text_view);
if(attributeSet != null) {
TypedArray a = context.getTheme().obtainStyledAttributes(
attributeSet,
R.styleable.ProfileInfoTextView,
0, 0);
try {
mTitleTextView.setText(a.getString(R.styleable.ProfileInfoTextView_setTitle));
String number = getNumber(a.getInt(R.styleable.ProfileInfoTextView_setNumber,1000));
mNumberTextView.setText(number);
} finally {
a.recycle();
}
}
}
발췌문에서
public class Account {
private Integer posts;
public Integer getPosts() {
return posts;
}
public void setPosts(Integer posts) {
this.posts = posts;
}
}
Account.class
은 자동 생성 된 GreenDao 데이터 클래스입니다.
내가 전달하려고하는 값은 정수 또는 int입니다. 둘 다 작동하지 않습니다. 오직 내가 xml 파일에서 하드 코드 할 때. 예외 메시지
Caused by: java.lang.RuntimeException: Found data binding errors.
****/ data binding error ****msg:Cannot find the setter for attribute 'app:setNumber' with parameter type java.lang.String on com.projet.Core.Views.ProfileInfoItemView. file:/Users/jemilriahi/ProjectNinjo/app/src/main/res/layout/fragment_my_account.xml loc:81:35 - 81:63 ****\ data binding error ****
at android.databinding.tool.processing.Scope.assertNoError(Scope.java:110)
at android.databinding.annotationprocessor.ProcessDataBinding.process(ProcessDataBinding.java:76)
at com.sun.tools.javac.processing.JavacProcessingEnvironment.callProcessor(JavacProcessingEnvironment.java:794)
at com.sun.tools.javac.processing.JavacProcessingEnvironment.discoverAndRunProcs(JavacProcessingEnvironment.java:705)
at com.sun.tools.javac.processing.JavacProcessingEnvironment.access$1800(JavacProcessingEnvironment.java:91)
at com.sun.tools.javac.processing.JavacProcessingEnvironment$Round.run(JavacProcessingEnvironment.java:1035)
at com.sun.tools.javac.processing.JavacProcessingEnvironment.doProcessing(JavacProcessingEnvironment.java:1176)
at com.sun.tools.javac.main.JavaCompiler.processAnnotations(JavaCompiler.java:1170)
at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:856)
at com.sun.tools.javac.main.Main.compile(Main.java:523)
누구나가 작동하지 않는 이유를 알아? 모든 도움을 주실 수 있습니다
'account'와'posts' 필드에 대한 클래스 유형을 공유 할 수 있습니까? – yigit
추가됨 :)하지만 그 클래스에는 그다지 많지 않습니다. –