@Override public View getGroupView( int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) { View view = convertView; GroupViewHolder holder; if (view == null) { view = inflater.inflate(R.layout.list_group_student, null, false); holder = new GroupViewHolder(); holder.studentName = (TextView) view.findViewById(R.id.studentName); view.setTag(holder); } else { holder = (GroupViewHolder) view.getTag(); } Student student = studentList.get(groupPosition); holder.student = student; holder.position = groupPosition; holder.studentName.setText(student.getEmail().split("@")[0]); return view; }
@Override public View getChildView( int groupPosition, int childPosition, boolean isLastChild, View convertView, ViewGroup parent) { View view = convertView; ItemViewHolder holder; if (view == null) { view = inflater.inflate(R.layout.list_item_student, null, false); holder = new ItemViewHolder(); holder.editStudentEmail = (ImageButton) view.findViewById(R.id.editStudentEmail); holder.studentEmail = (TextView) view.findViewById(R.id.studentEmail); // holder.parentEmail = (TextView) view.findViewById(R.id.parentEmail); // holder.parentEmailList = (ListView) view.findViewById(R.id.parentEmailList); holder.studentPanel = (LinearLayout) view.findViewById(R.id.studentPanel); holder.parentEmailLayout = (LinearLayout) view.findViewById(R.id.parentEmailLayout); view.setTag(holder); } else { holder = (ItemViewHolder) view.getTag(); } Student student = studentList.get(groupPosition); holder.student = student; holder.position = childPosition; holder.studentEmail.setText(student.getEmail()); for (String s : student.getParentEmailList()) { TextView textView = new TextView(context); textView.setText(s); textView.setTextColor(context.getResources().getColor(R.color.dark_blue)); textView.setPadding(5, 5, 5, 5); holder.parentEmailLayout.addView(textView); } // holder.parentEmailList.setAdapter(new ParentAdapter(context, // student.getParentEmailList())); holder.editStudentEmail.setTag(student); holder.editStudentEmail.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { Student student1 = (Student) v.getTag(); Intent updateStudent = new Intent(context, TeacherInviteStudent.class); updateStudent.putExtra( TeacherInviteStudent.EXTRA_CLASS_CODE, teacherClass.getClassCode()); updateStudent.putExtra(TeacherInviteStudent.EXTRA_CLASS_ID, teacherClass.getId()); updateStudent.putExtra(TeacherInviteStudent.EXTRA_STUDENT_ID, student1.getUserId()); updateStudent.putExtra(TeacherInviteStudent.EXTRA_STUDENT_EMAIL, student1.getEmail()); updateStudent.putStringArrayListExtra( TeacherInviteStudent.EXTRA_PARENT_EMAIL, student1.getParentEmailList()); updateStudent.putExtra(TeacherInviteStudent.EXTRA_IS_FIRST_TIME, false); context.startActivityForResult( updateStudent, TeacherShowClassStudentsActivity.REQUEST_UPDATE_STUDENT); } }); return view; }