大家好,我是使用 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.javapublic class Pop extends Activity implements Serializable {private FirebaseFirestore surveyDb = FirebaseFirestore.getInstance();
1 回答
HUX布斯
TA贡献1876条经验 获得超6个赞
AnketItemAdapter mAnketItemAdapter = new AnketItemAdapter(this ,mAnketList);
这里的this是指OnCompleteListener
您创建的实例,而不是Activity
(这是一个上下文)。试试Pop.this
吧,这将引用外部 Activity 实例。
添加回答
举报
0/150
提交
取消