Created
November 24, 2009 16:28
-
-
Save shaobin0604/241993 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class RowAdapter extends CursorAdapter { | |
| private final LayoutInflater mInflater; | |
| public RowAdapter(Context context, Cursor c, boolean autoRequery) { | |
| super(context, c, autoRequery); | |
| mInflater = LayoutInflater.from(context); | |
| } | |
| public RowAdapter(Context context, Cursor c) { | |
| super(context, c); | |
| mInflater = LayoutInflater.from(context); | |
| } | |
| @Override | |
| public void bindView(View view, Context context, Cursor cursor) { | |
| TextView tvDate = (TextView) view.findViewById(R.id.tv_date); | |
| TextView tvTime = (TextView) view.findViewById(R.id.tv_time); | |
| TextView tvWeek = (TextView) view.findViewById(R.id.tv_week); | |
| TextView tvVs = (TextView) view.findViewById(R.id.tv_vs); | |
| StringBuilder date = new StringBuilder(cursor.getString(cursor | |
| .getColumnIndex(DatabaseHelper.C_DATE))); | |
| StringBuilder time = new StringBuilder(cursor.getString(cursor | |
| .getColumnIndex(DatabaseHelper.C_TIME))); | |
| String week = cursor.getString(cursor | |
| .getColumnIndex(DatabaseHelper.C_WEEK)); | |
| String vs = cursor | |
| .getString(cursor.getColumnIndex(DatabaseHelper.C_VS)); | |
| if (DateFormat.format("yyyyMMdd", System.currentTimeMillis()) | |
| .toString().equals(date.toString())) { | |
| view.setBackgroundColor(Color.BLUE); | |
| } | |
| tvDate.setText(date.insert(4, '-').insert(7, '-')); | |
| tvTime.setText(time.insert(time.length() - 2, ':')); | |
| tvWeek.setText(week); | |
| tvVs.setText(vs); | |
| } | |
| @Override | |
| public View newView(Context context, Cursor cursor, ViewGroup parent) { | |
| final View view = mInflater.inflate(R.layout.list_item, parent, false); | |
| return view; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment