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 w w . j av a2 s.c om*/ 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 ExamsPendingCardAdapter extends CursorAdapter { private Context context; public ExamsPendingCardAdapter(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.exam_pending_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.pending_course_name); view_handler.semester = (TextView) convertView.findViewById(R.id.pending_semester); String c_name = cursor.getString(cursor.getColumnIndex(DB_ABSTRACTS.DBCourse.NAME_COLUMN)); String c_semester = cursor.getString(cursor.getColumnIndex(DB_ABSTRACTS.DBCourse.SEMESTER_COLUMN)); view_handler.course_name.setText(c_name); view_handler.semester.setText("Pending since " + c_semester); } //Create a holder class to contain all the view to inflate private static class Handler { TextView course_name; TextView semester; } }