我在 android 中构建了一个底部导航选项卡栏,它有 5 个片段,但问题是在应用程序启动时它不会从 firestore 数据库加载 recyclerview 列表。这个片段就是Home Fragment。但如果我随机打开另一个选项卡,然后进入主页选项卡,主页选项卡列表会自行加载,但不会在应用程序启动时自动加载
下面是代码。请协助
public class MainActivity extends AppCompatActivity
implements NavigationView.OnNavigationItemSelectedListener {
private static final String TAG = "DocSnippets";
private FirebaseAuth mauth;
private FirebaseFirestore db = FirebaseFirestore.getInstance();
private CollectionReference UsersRef = db.collection("Users");
private DocumentReference noteRef = db.document("Notebook/My First Note");
private MySharedPreferences sp;
private DocumentReference currentUserRef;
private Button notificationList;
private String mUserId, tokenId, currentUserProfilePic, currentUserName, currentUserSpinnerC;
String currentUserID;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
sp = MySharedPreferences.getInstance(this);
setContentView(R.layout.activity_main);
mauth = FirebaseAuth.getInstance();
// currentUserID = mauth.getCurrentUser().getUid();
UsersRef =FirebaseFirestore.getInstance().collection("Users");
mUserId = mauth.getUid();
tokenId = FirebaseInstanceId.getInstance().getToken();
Toolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
FloatingActionButton fab = findViewById(R.id.fab);
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
.setAction("Action", null).show();
}
});
}
冉冉说
慕无忌1623718
MYYA
相关分类