Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Ok I finally figured out what you really wanted.</p> <p>Instead of using "SimpleCursorAdapter" directly, you can create your own Cursor adapter, inside which you can mainipulate the data as you want. Create a new Adapter "SubjectsAdapter.java". In this Adapter you will override the "bindView" and "newView". This allows us to apply a view to the cursor. But before doing so, gives us the opportunity to change the data from the cursor.</p> <p>This will give you an idea what has to be done.</p> <pre><code> private void fillData() { cursor = mDbAdapter.fetchAllSubjects(); startManagingCursor(cursor); SubjectsAdapter subjectsAdapter = new SubjectsAdapter(this, cursor); setListAdapter(subjectsAdapter); } //SubjectsAdapter.java - make changes to fix bugs/compilation errors. This is untested. public class SubjectsAdapter extends ResourceCursorAdapter { public SubjectsAdapter(Context context, Cursor cur) { super(context, R.layout.subject_row, cur); } @Override public View newView(Context context, Cursor cur, ViewGroup parent) { LayoutInflater li = (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE); return li.inflate(R.layout.subject_row, parent, false); } @Override public void bindView(View view, Context context, Cursor cursor) { TextView titleText = (TextView)view.findViewById(R.id.title); titleText.setText(cursor.getString(cursor.getColumnIndex(DatabaseAdapter.KEY_TITLE))); //You can add code to retrieve other columns here. //This is where you retrieve the date in long format from cursor, convert it to a required format, and then using it. TextView beginTimeText = (TextView)view.findViewById(R.id.time); Long lBeginDate = cursor.getLong(cursor.getColumnIndex(DatabaseAdapter.KEY_BEGIN)); String sBeginDate = getFormattedDate(lBeginDate); beginTimeText.setText(sBeginDate); } private String getFormattedDate(Long lDate) { SimpleDateFormat smdf = new SimpleDateFormat("MM/dd/yyyy h:mm:ss a"); String sDate = smdf.format( lDate )); return sDate; } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload