@Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        View rootView = inflater.inflate(R.layout.queue_list, container, false);
        //Instantiate Firebase objects
        mDatabase = FirebaseDatabase.getInstance(); //instance of Firebase object(i.e. database root object)
        mDepositQueueReference = mDatabase.getReference("depositQueue"); //reference to depositQueue child object in root object
        //Instantiate other variables
        queueListView = rootView.findViewById(R.id.list);
        loadingIndicator = rootView.findViewById(R.id.loading_indicator);
        final List<Payment> paymentsList = new ArrayList<Payment>();
        postAdapter = new QueueAdapter(getActivity(), R.layout.queue_view, paymentsList);
        queueListView.setAdapter(postAdapter);
        /**Delete this post adapter when you finish*/
//        postAdapter.add(new Payment("James Blunt", "0149603509", "4500", "WAEC", "07033513241", "igwenus619@gmail.com"));
        //Add ChildEventListener, so that changes made in the database are reflected
        mChildEventListener = new ChildEventListener() {
            @Override
            public void onChildAdded(DataSnapshot dataSnapshot, String s) {
                if (dataSnapshot.exists()) {
                    loadingIndicator.setVisibility(View.GONE);
                    Payment payment = dataSnapshot.getValue(Payment.class);
                    /**Uncomment this when you've finished*/
                    postAdapter.add(payment); //here, you could use queueListView.add() too
                }
            }
            @Override
            public void onChildChanged(DataSnapshot dataSnapshot, String s) {
            }
            @Override
            public void onChildRemoved(DataSnapshot dataSnapshot) {
            }
            @Override
            public void onChildMoved(DataSnapshot dataSnapshot, String s) {
            }
            @Override
            public void onCancelled(DatabaseError databaseError) {
                Log.e(TAG, "postComments:onCancelled", databaseError.toException());
            }
        };
        mDepositQueueReference.addChildEventListener(mChildEventListener);
        queueListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                Payment payment = paymentsList.get(position);
                Intent intent = new Intent(getActivity(), ConfirmDetailsActivity.class);
                intent.putExtra("pushID", payment.getPushID());
                intent.putExtra("accountName", payment.getAccountName());
                intent.putExtra("accountNumber", payment.getAccountNumber());
                intent.putExtra("depositAmount", payment.getDepositAmount());
                intent.putExtra("depositorName", payment.getDepositorName());
                intent.putExtra("depositorPhoneNumber", payment.getDepositorPhoneNumber());
                intent.putExtra("depositorEmail", payment.getDepositorEmail());
                Log.e(TAG, "Phone Number" + payment.depositorPhoneNumber);
                startActivity(intent);
            }
        });
        return rootView;
    }
@Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        View rootView = inflater.inflate(R.layout.queue_list, container, false);
       
        mDatabase = FirebaseDatabase.getInstance();
        mDepositQueueReference = mDatabase.getReference("depositQueue");
       
        queueListView = rootView.findViewById(R.id.list);
        loadingIndicator = rootView.findViewById(R.id.loading_indicator);
        final List<Payment> paymentsList = new ArrayList<Payment>();
        postAdapter = new QueueAdapter(getActivity(), R.layout.queue_view, paymentsList);
        queueListView.setAdapter(postAdapter);
       
       
        mChildEventListener = new ChildEventListener() {
            @Override
            public void onChildAdded(DataSnapshot dataSnapshot, String s) {
                if (dataSnapshot.exists()) {
                    loadingIndicator.setVisibility(View.GONE);
                    Payment payment = dataSnapshot.getValue(Payment.class);
                   
                    postAdapter.add(payment);
                }
            }
            @Override
            public void onChildChanged(DataSnapshot dataSnapshot, String s) {
            }
            @Override
            public void onChildRemoved(DataSnapshot dataSnapshot) {
            }
            @Override
            public void onChildMoved(DataSnapshot dataSnapshot, String s) {
            }
            @Override
            public void onCancelled(DatabaseError databaseError) {
                Log.e(TAG, "postComments:onCancelled", databaseError.toException());
            }
        };
        mDepositQueueReference.addChildEventListener(mChildEventListener);
        queueListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                Payment payment = paymentsList.get(position);
                Intent intent = new Intent(getActivity(), ConfirmDetailsActivity.class);
                intent.putExtra("pushID", payment.getPushID());
                intent.putExtra("accountName", payment.getAccountName());
                intent.putExtra("accountNumber", payment.getAccountNumber());
                intent.putExtra("depositAmount", payment.getDepositAmount());
                intent.putExtra("depositorName", payment.getDepositorName());
                intent.putExtra("depositorPhoneNumber", payment.getDepositorPhoneNumber());
                intent.putExtra("depositorEmail", payment.getDepositorEmail());
                Log.e(TAG, "Phone Number" + payment.depositorPhoneNumber);
                startActivity(intent);
            }
        });
        return rootView;
    }
@override public view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate) { view rootview = inflater.inflate(r.layout.queue_list, container, false); mdatabase = firebasedatabase.getinstance(); mdepositqueuereference = mdatabase.getreference("depositqueue"); queuelistview = rootview.findviewbyid(r.id.list); loadingindicator = rootview.findviewbyid(r.id.loading_indicator); final list<payment> paymentslist = new arraylist<payment>(); postadapter = new queueadapter(getactivity(), r.layout.queue_view, paymentslist); queuelistview.setadapter(postadapter); mchildeventlistener = new childeventlistener() { @override public void onchildadded(datasnapshot datasnapshot, string s) { if (datasnapshot.exists()) { loadingindicator.setvisibility(view.gone); payment payment = datasnapshot.getvalue(payment.class); postadapter.add(payment); } } @override public void onchildchanged(datasnapshot datasnapshot, string s) { } @override public void onchildremoved(datasnapshot datasnapshot) { } @override public void onchildmoved(datasnapshot datasnapshot, string s) { } @override public void oncancelled(databaseerror databaseerror) { log.e(tag, "postcomments:oncancelled", databaseerror.toexception()); } }; mdepositqueuereference.addchildeventlistener(mchildeventlistener); queuelistview.setonitemclicklistener(new adapterview.onitemclicklistener() { @override public void onitemclick(adapterview<?> parent, view view, int position, long id) { payment payment = paymentslist.get(position); intent intent = new intent(getactivity(), confirmdetailsactivity.class); intent.putextra("pushid", payment.getpushid()); intent.putextra("accountname", payment.getaccountname()); intent.putextra("accountnumber", payment.getaccountnumber()); intent.putextra("depositamount", payment.getdepositamount()); intent.putextra("depositorname", payment.getdepositorname()); intent.putextra("depositorphonenumber", payment.getdepositorphonenumber()); intent.putextra("depositoremail", payment.getdepositoremail()); log.e(tag, "phone number" + payment.depositorphonenumber); startactivity(intent); } }); return rootview; }