This is my ListActivity:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.my_list);
mDbHelper = new MyDbAdapter(this);
mDbHelper.open();
fillData();
registerForContextMenu(getListView());
}
private void fillData() {
Cursor c = mDbHelper.fetchAllTransactions();
startManagingCursor(c);
String[] from = new String[]{MyDbAdapter.KEY_DATE, MyDbAdapter.KEY_NAME};
int[] to = new int[]{R.id.row_date, R.id.row_name};
setListAdapter(new SimpleCursorAdapter(this, R.layout.my_list_row, c, from, to));
}
and this is my line layout:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<TextView android:id="@+id/row_date" android:layout_width="wrap_content" android:layout_height="fill_parent" />
<TextView android:id="@+id/row_name" android:layout_width="wrap_content" android:layout_height="fill_parent" />
</LinearLayout>
The date is actually stored as an int in the SQLLite database and therefore is displayed as an integer.
Does anyone know a way to create a date from an int, so it doesn't show up as 1216544611(or something else), but how "12/11/2009 11:32"?
source
share