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

  • Home
  • SEARCH
  • 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 989079
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T05:44:04+00:00 2026-05-16T05:44:04+00:00

I have a problem displaying the results of an sql query into a ListView

  • 0

I have a problem displaying the results of an sql query into a ListView via SimpleCursorAdapter. This is my query:

String sql = "" +
"SELECT (Clients.firstname || \" \" ||  Clients.surname) AS client_name, " +
    "Visits._id, " +
    "Status.status, " +
 "strftime('%H:%M',time(sql_start_date,'unixepoch')) as start_time, " +
 "strftime('%H:%M',time(sql_end_date,'unixepoch')) as end_time " + 
 "FROM " +
         "Visits,Clients,Status " +
 "WHERE " +
         "Visits.status = Status.remote_id " +
 "AND " +
         "Visits.client_id = Clients.remote_id " +
 "AND " +
  "Visits.sql_start_date > "+checkpoint+" " +
 "AND " +
  "Visits.sql_end_date < "+endpoint;

when I execute this query I get a typical result set like so:

client_name   |Visit._id|Status.status |start_time |end_time
__________________________________________________________
Kevin Bradshaw|187      |Pending       |13:00      |14:00
Peter Flynn   |193      |Pending       |15:00      |16:30

I want to output this cursor to a listview.
The problem I run into is that i can output client name and status no problems, but the start_time and end_time fields remain blank.

my cursor adapter code is this:

Cursor cur = HomeScreen.this.application.getVisitsHelper().fetchVisits();
startManagingCursor(cur);
// the desired columns to be bound     
String[] columns = new String[] {VisitsAdapter.KEY_CLIENT_FULL_NAME, VisitsAdapter.KEY_STATUS,VisitsAdapter.KEY_CLIENT_START_TIME, VisitsAdapter.KEY_CLIENT_END_TIME};

// the XML defined views which the data will be bound to
int[] to = new int[] { R.id.name_entry,R.id.number_entry,R.id.start_time_display,R.id.end_time_display  };

// create the adapter using the cursor pointing to the desired data as well as the layout information
SimpleCursorAdapter mAdapter = new SimpleCursorAdapter(HomeScreen.this, R.layout.list_element, cur, columns, to);

// set this adapter as ListActivity's adapter
HomeScreen.this.setListAdapter(mAdapter);

And finally my xml layout (list_element.xml) is as follows:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
 android:orientation="vertical"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" 
        >
    <TextView
     android_id="@+id/start_time_display"
     android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  android:textSize="16dip" 
  android:textColor="#333333" 
  android:layout_marginLeft="14px"
 ></TextView>
    <TextView
     android_id="@+id/end_time_display"
     android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  android:textSize="16dip" 
  android:textColor="#333333" 
  android:layout_toRightOf="@+id/start_time_display"
  android:layout_marginLeft="64px"></TextView>
 <TextView
  android:id="@+id/name_entry"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  android:textSize="16dip" 
  android:textColor="#333333" 
  android:layout_marginLeft="94px"
  android:layout_toRightOf="@+id/end_time_display"/>
       <TextView
  android:id="@+id/number_entry"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  android:textSize="14dip"
  android:textColor="#666666" 
  android:layout_marginLeft="14px"
  android:layout_below="@+id/name_entry"
  />
</RelativeLayout>

So my question is, how come some of the code (i.e. status and client name) is getting output while my time fields (start_time, end_time) are not?

Is it because simple cursor adapters can only deal with ints and strings and my time variables originate from sql timestamps in the database?

  • 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-16T05:44:05+00:00Added an answer on May 16, 2026 at 5:44 am

    Sorry guys, dont waste your time on this.

    the problem was a typo.. I referred to android_id in my xml file when it should have been android:id

    thanks anyway

    Kev

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My problem is that I have a user that is having a problem displaying
I have problem compilin this code..can anyone tell whats wrong with the syntax CREATE
I have problem when I try insert some data to Informix TEXT column via
I have problem in some JavaScript that I am writing where the Switch statement
I have problem with return statment >.< I want to store all magazine names
I have problem with starting processes in impersonated context in ASP.NET 2.0. I am
I have problem with ActionLink. I'd like to pass to my ActionLink parameter for
I do not have problem as such but I am quite new to Ruby.
I have a problem using the Java search function in Eclipse on a particular
I have a problem with a little .Net web application which uses the Amazon

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.