我是Android的新手,遇到了一些问题,我正在制作一个StudentArraylist来查看我的firebase数据库中的学生,以便在ListView中显示它们。但我面临一些问题,因为我现在的代码我的意思是片段但不是活动和 这是我的错误 这是ViewStudentActivity
StudentArrayList adapter = new StudentArrayList(getActivity(),studentList);
studentlist.setAdapter(adapter);
这是StudentArrayList:
public StudentArrayList(Activity context, List<Student>studentList){
super(context, R.layout.student_list, studentList);
this.context = context;
this.studentList = studentList;
}
@NonNull
@Override
public View getView(int position, @Nullable View convertView, @NonNull
ViewGroup parent) {
LayoutInflater inflater = context.getLayoutInflater();
View listViewItem = inflater.inflate(R.layout.student_list, null, true);
s_sid = (TextView)listViewItem.findViewById(R.id.txtSid);
s_name = (TextView)listViewItem.findViewById(R.id.txtName);
s_email = (TextView)listViewItem.findViewById(R.id.txtEmail);
s_fyp = (TextView)listViewItem.findViewById(R.id.s_fyp);
btnUpdate = (Button) listViewItem.findViewById(R.id.btnUpdate);
firebaseDatabase = FirebaseDatabase.getInstance();
pdatabaseReference = firebaseDatabase.getReference();
auth = FirebaseAuth.getInstance();
final Student student = studentList.get(position);
s_sid.setText("Student ID : " + student.gets_sid());
s_name.setText("Student Name : " +student.gets_name());
s_email.setText("Date : " +student.gets_email());
s_fyp.setText("Time Start : " +student.gets_fyp());
return listViewItem;
}