Back to project page calendar.
The source code is released under:
GNU General Public License
If you think the Android project calendar 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.dorosh.calendar.creator.ideacalendar.app.Cursors; // ww w . j a v a 2 s.co m 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.dorosh.calendar.creator.ideacalendar.app.R; import java.text.SimpleDateFormat; import java.util.Calendar; /** * Created by Admin on 17.06.2014. */ public class TODOCursorAdapter extends CursorAdapter { public TODOCursorAdapter(Context context, Cursor c, boolean autoRequery) { super(context, c, autoRequery); } @Override public View newView(Context context, Cursor cursor, ViewGroup parent) { LayoutInflater layoutInflater = LayoutInflater.from(context); View view = layoutInflater.inflate(R.layout.list_item, parent, false); bindView(view, context, cursor); return view; } @Override public void bindView(View view, Context context, Cursor cursor) { int nameIndex = cursor.getColumnIndex("name"); int locIndex = cursor.getColumnIndex("location"); int startIndex = cursor.getColumnIndex("start"); int endIndex = cursor.getColumnIndex("end"); int descIndex = cursor.getColumnIndex("description"); TextView name = (TextView) view.findViewById(R.id.title); name.setText(cursor.getString(nameIndex)); TextView description = (TextView) view.findViewById(R.id.description_view); description.setText(cursor.getString(descIndex)); TextView location = (TextView) view.findViewById(R.id.location); location.setText(cursor.getString(locIndex)); TextView startTime = (TextView) view.findViewById(R.id.start_time_show); long startStamp = cursor.getLong(startIndex); Calendar calendar = Calendar.getInstance(); calendar.setTimeInMillis(startStamp); SimpleDateFormat sdf = new SimpleDateFormat("HH:mm"); String start = sdf.format(calendar.getTime()); startTime.setText(start); TextView endTime = (TextView) view.findViewById(R.id.end_time); long endStamp = cursor.getLong(endIndex); Calendar endcalendar = Calendar.getInstance(); endcalendar.setTimeInMillis(endStamp); String end = sdf.format(endcalendar.getTime()); endTime.setText(end); } }