这是我现在正在使用的代码:
public void onDataChange(DataSnapshot dataSnapshot) {
for (DataSnapshot moviecatlog: dataSnapshot.getChildren()) {
Actors = (String) moviecatlog.child("Actors").getValue();
Description = (String) moviecatlog.child("Description").getValue();
Director = (String) moviecatlog.child("Director").getValue();
Genre = (String) moviecatlog.child("Genre").getValue();
Published = (String) moviecatlog.child("Published").getValue();
MovieUrl = (String) moviecatlog.child("MovieUrl").getValue();
Status = (String) moviecatlog.child("Status").getValue();
ThumbUrl = (String) moviecatlog.child("ThumbUrl").getValue();
Title = (String) moviecatlog.child("Title").getValue();
id = (String) moviecatlog.child("id").getValue();
// recyclerView.setAdapter(new RecyclerViewAdapter(moviecatlog));
ar = new ArrayList<String>();
ar.add(Actors);
ar.add(Description);
ar.add(Director);
ar.add(Genre);
ar.add(MovieUrl);
ar.add(Published);
ar.add(Status);
ar.add(ThumbUrl);
ar.add(Title);
ar.add(id);
recyclerView.setAdapter(new RecyclerViewAdapter(ar));
如何将数据放入ArrayList?现在,我只能将所有数据放在一起,但最后,它只显示ArrayList中最后一项的属性。
答案 0 :(得分:1)
Arraylist actor=new Arraylist ();
notification = new ArrayList<HashMap<String, String>>();
notification1 = new ArrayList<HashMap<String, String>>();
HashMap<String, String> list = new HashMap<String, String>;
actoredata[]={om puri ,raj,};
directore[]={mahesh bhatt,payrelal};
for(i=0;i<actoredatalenth(),i++){
list.put("actor", actore[i])));
notification.add(list);
}
actore.add(notification);
for(i=0;i<directorelenth(),i++){
list.put("actor", directore[i])));
notification.add(list);
}actore.add(notification);