正在尋找我在相當一段時間內做錯了什麼,希望能在這裏找到一些幫助。我正在嘗試從Firebase填充文本視圖。從Firebase填充Textview。錯誤:無法在參數'pathString'中傳遞null()
private TextView txtDetails;
private DatabaseReference mFirebaseDatabase;
private FirebaseDatabase mFirebaseInstance;
private String userId;
private EditText inputLastName;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.gb_personal_profile);
txtDetails = (TextView) findViewById(R.id.txt_profile_name);
mFirebaseDatabase =
FirebaseDatabase.getInstance().getReference("users");
mFirebaseDatabase.child(userId).addValueEventListener(new
ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
gbCreationUNameDB user =
dataSnapshot.getValue(gbCreationUNameDB.class);
txtDetails.setText(user.first_name);
}
@Override
public void onCancelled(DatabaseError databaseError) {
}
});
}
}
,這裏是用戶
import com.google.firebase.database.IgnoreExtraProperties;
@IgnoreExtraProperties
public class gbCreationUNameDB {
public String first_name;
public String last_name;
public gbCreationUNameDB() {
}
public gbCreationUNameDB(String first_name, String last_name) {
this.first_name = first_name;
this.last_name = last_name;
}
public String getfirst_name() {
return first_name;
}
}
幫助不勝感激。已經檢查了所有的資源,當你從dataSnapshot對象,你正在使用這行代碼得到的gbCreationUNameDB class
對象不能弄清楚
看來「用戶id」是當你試圖調用mFirebaseDatabase.child(用戶ID)... – Kim