如何使用Firebase创建simple_list_item_2列表

时间:2017-02-18 13:07:15

标签: android firebase

我可以创建simple_dropdown_item_1line,但我需要创建2行列表

ArrayList<String> list = new ArrayList<>();
ArrayAdapter<String> arrayAdapter;
ListView courses;
DatabaseReference databaseReference = FirebaseDatabase.getInstance().getReference();
    FirebaseAuth firebaseAuth = FirebaseAuth.getInstance();
    FirebaseUser user = firebaseAuth.getCurrentUser();
    final DatabaseReference database = databaseReference.child(user.getUid());
.
.
.
courses = (ListView)findViewById(R.id.courseList);
arrayAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_dropdown_item_1line, list);
courses.setAdapter(arrayAdapter);
database.child("Lessons").addChildEventListener(new ChildEventListener() {
            @Override
            public void onChildAdded(DataSnapshot dataSnapshot, String s) {
                list.add(dataSnapshot.getKey());
                arrayAdapter.notifyDataSetChanged();
            }

            @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) {

            }
        });

我创建了simple_dropdown_item_1line listView,并且一切正常。但我无法创建simple_dropdown_item_1line

0 个答案:

没有答案