我启动我的Google Firestore应用程序时将其关闭,但在Android Studio中没有错误。 请帮忙。
private DocumentReference mDocFef = FirebaseFirestore.getInstance().document("news/1");
public TextView News1TextView;
@Override
protected void onStart() {
super.onStart();
mDocFef.addSnapshotListener(new EventListener<DocumentSnapshot>() {
@Override
public void onEvent(@Nullable DocumentSnapshot documentSnapshot, @Nullable FirebaseFirestoreException e) {
String news1TitleText = documentSnapshot.getString("Title");
String news1ContentText = documentSnapshot.getString("Article");
News1TextView.setText(news1TitleText + " " + news1ContentText);
}
});
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
final TextView News1TextView = (TextView) findViewById(R.id.news1Title);
News1TextView.setText("123456789");
}