大家好,我是使用 Firebase Firestore 在 Android Studio 上开发完整应用程序的新手。我在 youtube 上关注带有 firestores 文档的视频,我想做的只是从我的“Anket”集合中获取所有文档,这是一个调查集合,并将它们列出在弹出屏幕上。感谢您的时间和友好的回答.
MainFragmentActivity.java:
public class MainFragmentActivity extends AppCompatActivity {
private static final String TAG = "MainActivity";
private SectionPageAdapter mSectionPageAdapter;
private ViewPager mViewPager;
FirebaseAuth mAuth = FirebaseAuth.getInstance();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main_fragment2);
Log.d(TAG,"onCreate:Starting");
mViewPager = findViewById(R.id.container);
setupViewPager(mViewPager);
mViewPager.setOffscreenPageLimit(4);
mSectionPageAdapter = new SectionPageAdapter(getSupportFragmentManager());
TabLayout tabLayout = findViewById(R.id.tabs);
tabLayout.setupWithViewPager(mViewPager);
}
private void setupViewPager(ViewPager viewPager){
SectionPageAdapter adapter = new SectionPageAdapter(getSupportFragmentManager());
adapter.addFragment(new ProfileFragment(), "Profile");
adapter.addFragment(new MessageFragment(), "Messages");
adapter.addFragment(new MatchFragment(), "Matches");
adapter.addFragment(new ShopFragment(), "Shop");
viewPager.setAdapter(adapter);
}
public void logoutUser(View view) {
mAuth.signOut();
Intent intent = new Intent (MainFragmentActivity.this, ChooseLoginRegistration.class);
startActivity(intent);
finish();
return;
}
public void openUpAnket (View view){
Intent intent = new Intent(MainFragmentActivity.this,Pop.class);
startActivity(intent);
}
}
Pop.java
public class Pop extends Activity implements Serializable {
private FirebaseFirestore surveyDb = FirebaseFirestore.getInstance();
HUX布斯
相关分类