Back to project page digitalcampus.
The source code is released under:
MIT License
If you think the Android project digitalcampus listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.llenguatges.digitalcampus.adapters; // w w w.j a v a 2 s . c o m import java.util.List; import android.content.Context; import android.graphics.Color; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ArrayAdapter; import android.widget.ImageView; import android.widget.TextView; import com.llenguatges.digitalcampus.R; import com.llenguatges.digitalcampus.database.StudentSubjectTable; import com.llenguatges.digitalcampus.objects.Student; public class SubjectStudentsAdapter extends ArrayAdapter<Student>{ private List<Student> data; /** * Constructor * @param _context * @param _studentArray */ public SubjectStudentsAdapter(Context _context, List<Student> _studentArray){ super(_context, android.R.layout.simple_list_item_1); data = _studentArray; } /** * Get the data item associated with the specified position in the data set. * @param index * @return data */ public Student getItem(int index) { return this.data.get(index); } /** * Get how many items are in the data set represented by this Adapter. */ public int getCount() { return this.data.size(); } /** * Get a View that displays the data at the specified position in the data set. * @param position * @param converView * @param parent */ public View getView(int position, View convertView, ViewGroup parent) { View row = convertView; if (row == null) { LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE); row = inflater.inflate(R.layout.subject_students_layout, parent, false); } Student student = new Student(0, null, null, null, null, null, false, null); student = getItem(position); TextView firstName = (TextView) row.findViewById(R.id.subject_studentListFirstName); firstName.setText(student.getFirstName()); firstName.setTextColor(Color.BLACK); TextView lastName = (TextView) row.findViewById(R.id.subject_studentListLastName); lastName.setText(student.getLastName()); lastName.setTextColor(Color.BLACK); TextView description = (TextView) row.findViewById(R.id.subject_studentListDescription); description.setText(student.getDescription()); description.setTextColor(Color.BLACK); ImageView iv = (ImageView) row.findViewById(R.id.subject_studentListImage); if(student.getPhoto() != null){ iv.setImageBitmap(student.getPhoto()); }else{ iv.setImageResource(R.drawable.ic_launcher); } return row; } /** * Delete student from student's table by student id * @param id */ public void deleteStudent(long id){ StudentSubjectTable stSbTable = new StudentSubjectTable(getContext()); stSbTable.DeleteByStudentID(id); } }