使用Fragment类

时间:2018-01-19 17:03:42

标签: android firebase firebase-realtime-database

我的类扩展了Fragment(使用标签式活动),下面的代码是onCreate()方法。但是当我尝试运行时,我的应用程序崩溃了。是否无法使用Fragment扩展类从firebase检索数据?或者我从其他问题中读到它说我应该使用RecyclerView。请指教。

        @Override
        public void onDataChange(DataSnapshot dataSnapshot) {

            for (DataSnapshot ds : dataSnapshot.getChildren()) {
                //check type if student
                no = Integer.parseInt(ds.child("name").getValue().toString());
                driverName = ds.child("id").getValue().toString();
                route = ds.child("mother").getValue().toString();
                String schedule1 = ds.child("father").getValue().toString();
                status = ds.child("status").getValue().toString();
                user.put(Integer.parseInt(ds.getKey().toString()), new User(name, id, father, mother, status));
            }
        }

        @Override
        public void onCancelled(DatabaseError databaseError) {
            Log.w("LogFragment", "loadLog:onCancelled", databaseError.toException());
        }
    });

提前致谢!

0 个答案:

没有答案
相关问题