Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 499035
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T05:56:39+00:00 2026-05-13T05:56:39+00:00

This is my ListActivity: @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.my_list); mDbHelper =

  • 0

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() {
    // Get all of the rows from the database and create the item list
    Cursor c = mDbHelper.fetchAllTransactions();
    startManagingCursor(c);

    // Create an array to specify the fields we want to display in the list
    String[] from = new String[]{MyDbAdapter.KEY_DATE, MyDbAdapter.KEY_NAME};

    // and an array of the fields we want to bind those fields to
    int[] to = new int[]{R.id.row_date, R.id.row_name};

    // Now create a simple cursor adapter and set it to display
    setListAdapter(new SimpleCursorAdapter(this, R.layout.my_list_row, c, from, to));
}

and this is my row 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 thus it displays as an integer.

Does anyone know a way to create a date from the int so it doesn’t display as 1216544611 (or whatever) but as "12/11/2009 11:32"?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T05:56:40+00:00Added an answer on May 13, 2026 at 5:56 am

    I suspect that you will need to write your own CursorAdapter that formats the int into a date string. The trick is to implement bindView() to format the list item before it is displayed:

    private final class MyCursorAdapter extends CursorAdapter {
        MyCursorAdapter(Context context, Cursor c) {
            super(context, c);
        }
    
        @Override public void bindView(View view, Context context, Cursor cursor) {             
    
            // Format the date string
            TextView dateView = (TextView) view.findViewById(R.id.row_date);
            long millis = cursor.getLong(cursor.getColumnIndex(MyDbAdapter.KEY_DATE));
            dateView.setText(DateFormat.getDateInstance().format(new Date(milis)));
    
            // Do the rest of your view formatting
            ...
        }
    
        @Override View public newView(Context context, Cursor cursor, ViewGroup parent) {        
            View view = getLayoutInflater().inflate(R.layout.my_list_row, null);
            bindView(view, context, cursor);
            return view;        
        }
    }
    

    and connect it to your Activity in onCreate():

    setListAdapter(new MyCursorAdapter(this, c));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is the class Db.java package calc.three; import java.io.IOException; import android.app.Activity; import android.app.ListActivity; import
Okay, i am new for android developping, or any developping and getting this error.
this is my first question in here, and I would like to ask if
This question is directly related to this SO question I posed about 15 minutes
This question is kind of a follow up to this question I asked a
This should be a simple one: I have an observableArray object called To in
This sequence satisfies a(n+2) = 2 a(n+1) + 2 a(n). and also a(n)=[(1+sqrt(3))^(n+2)-(1-sqrt(3))^(n+2)]/(4sqrt(3)). I
This is my code: <CheckBox android:id=@+id/sprint_checkbox android:layout_width=fill_parent android:layout_height=wrap_content android:text=@string/sprint_game /> <CheckBox android:id=@+id/marathon_checkbox android:layout_width=fill_parent android:layout_height=wrap_content
This code below allows me to find the word error in all my files
This works. $(document).ready(function(){ $(.items article).click(function(){ window.location=$(this).find(a).attr(href); return false; }); }); However , when the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.