in EditExt Beobachtete immer habe ich eine ModellklasseObservableArrayMap mit Objekt als Wert nicht auf Wertänderung
public class ScopeDefination extends BaseObservable {
String value;
String key;
boolean isPrivate;
String category;
public String getCategory() {
return category;
}
public void setCategory(String category) {
this.category = category;
}
public ScopeDefination(String key, String value, boolean isPrivate) {
this.key = key;
this.value = value;
this.isPrivate = isPrivate;
}
public ScopeDefination(String key, String value, boolean isPrivate, String category) {
this.key = key;
this.value = value;
this.isPrivate = isPrivate;
this.category = category;
}
@Bindable
public String getKey() {
return key;
}
public void setKey(String key) {
this.key = key;notifyPropertyChanged(developer.manish.publicprivatescopecategory.BR.key);
}
@Bindable
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
notifyPropertyChanged(developer.manish.publicprivatescopecategory.BR.value);
}
public boolean isPrivate() {
return isPrivate;
}
public void setPrivate(boolean aPrivate) {
isPrivate = aPrivate;
}
}
und ich versuche, es in einer Klasse wie diese
Bindung für Daten zu verwenden,ScopeDefination scopeDefination1 = new ScopeDefination(Keys.ADDRESS_HOME,"Address", true, Keys.FINANCIAL_INFO);
ScopeDefination scopeDefination2 = new ScopeDefination(Keys.NAME,"Name", true, Keys.FINANCIAL_INFO);
ObservableArrayMap<String, Object> user = new ObservableArrayMap<>();
user.put(Keys.ADDRESS_HOME, scopeDefination1);
user.put(Keys.NAME, scopeDefination2);
fragmentFirebaseBinderBinding = DataBindingUtil.inflate(inflater, R.layout.fragment_firebase_binder, container, false);
fragmentFirebaseBinderBinding.setUser(user);
Meine XML ist
<?xml version="1.0" encoding="utf-8"?>
<data>
<import type="developer.manish.publicprivatescopecategory.ScopeDefination" />
<import type="android.databinding.ObservableMap" />
<variable
name="user"
type="ObservableMap<String, Object>" />
</data>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context="developer.manish.publicprivatescopecategory.FirebaseBinder">
<TextView
android:id="@+id/name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text='@{((ScopeDefination)user["username"]).getValue()}'/>
<TextView
android:id="@+id/address"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text='@{((ScopeDefination)user["address_home"]).getValue()}' />
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:text='@{((ScopeDefination)user["username"]).getValue()}' />
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:text='@{((ScopeDefination)user["address_home"]).getValue()}' />
</LinearLayout>
Ich bin der Lage, Daten auf UI zu zeigen, aber wenn ich die entsprechende Textansicht immer aktualisiert keine Daten in EditExt bearbeiten.
Fehler: (26, 27) Kein Ressourcentyp angegeben (bei 'text' mit Wert '@ = {((ScopeDefination) user ["Benutzername"]). GetValue()}'). –
bekommen diesen Fehler danach –
Sieht aus wie ein Tippfehler. Überprüfen Sie das. – yennsarah