Back to project page ProjectStudio.
The source code is released under:
Apache License
If you think the Android project ProjectStudio 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 adapters; /*w ww . ja va 2 s.com*/ import android.content.Context; import android.database.Cursor; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.CursorAdapter; import android.widget.TextView; import com.example.uniutilproject.R; import DB_Provider.DB_ABSTRACTS; /** * Created by desmond on 1/30/14. */ public class ExamsPassedCardAdapter extends CursorAdapter { private Context context; public ExamsPassedCardAdapter(Context context, Cursor c, boolean autoRequery) { super(context, c, autoRequery); this.context = context; } @Override public View newView(Context context, Cursor cursor, ViewGroup parent) { // when the view will be created for first time, // we need to tell the adapters, how each item will look LayoutInflater inflater = LayoutInflater.from(parent.getContext()); View retView = inflater.from(context).inflate(R.layout.exams_passed_listitem, parent, false); return retView; } @Override public void bindView(View convertView, Context context, Cursor cursor) { // here we are setting our data // that means, take the data from the cursor and put it in views Handler view_handler = new Handler(); view_handler.course_name = (TextView) convertView.findViewById(R.id.passed_course_name); view_handler.semester = (TextView) convertView.findViewById(R.id.passed_semester); view_handler.pass_score = (TextView) convertView.findViewById(R.id.passed_score); String c_name = cursor.getString(cursor.getColumnIndex(DB_ABSTRACTS.DBCourse.NAME_COLUMN)); String c_semester = cursor.getString(cursor.getColumnIndex(DB_ABSTRACTS.DBCourse.SEMESTER_COLUMN)); String c_score = cursor.getString(cursor.getColumnIndex(DB_ABSTRACTS.DBCourse.PASS_MARK_COLUMN)); view_handler.course_name.setText(c_name); view_handler.semester.setText("From " + c_semester); view_handler.pass_score.setText("Passed with " + c_score); } //Create a holder class to contain all the view to inflate private static class Handler { TextView course_name; TextView semester; TextView pass_score; } }