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 986515
In Process

The Archive Base Latest Questions

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

I have an app that will query a database and attempt to output results

  • 0

I have an app that will query a database and attempt to output results in a list format.

my first attempt was to use a simpleCursorAdapter, which worked fine for string outputs such as name and status, but would not display the time field from my cursor. My time field in my data base is of type Timestamp. the query for the time field is

"strftime('%H:%M',time(sql_start_date,'unixepoch')) as start_time, " +

A little bit of research and it turns out that SimpleCursorAdapters only work for strings. I found this a little confusing as I would have thought that the field start_time was in the format of a string (after all I can view the result in the Log window by saying:

Log.i(TAG,start_time);

So my next attempt is to use my own custom CursorAdapter:

private class MyVisitsAdapter extends CursorAdapter{
     private Cursor mCursor;
     private Context mContext;
     private final LayoutInflater mInflater;

     public MyVisitsAdapter(Context context, Cursor cursor) {
       super(context, cursor, true);
       mInflater = LayoutInflater.from(context);
       mContext = context;
     }

     @Override
     public void bindView(View view, Context context, Cursor cursor) {
      String st = cursor.getString(cursor.getColumnIndex(VisitsAdapter.KEY_CLIENT_START_TIME));
      Log.i("Check Cursor result",st);
      TextView t = (TextView) view.findViewById(R.id.start_time_display);

      t.setText(st);


       TextView t1 = (TextView) view.findViewById(R.id.end_time_display);
       t.setText(cursor.getString(cursor.getColumnIndex(VisitsAdapter.KEY_CLIENT_END_TIME)));

       t = (TextView) view.findViewById(R.id.name_entry);
       t.setText(cursor.getString(cursor.getColumnIndex(VisitsAdapter.KEY_CLIENT_FULL_NAME)));
     }

     @Override
     public View newView(Context context, Cursor cursor, ViewGroup parent) {
       final View view = mInflater.inflate(R.layout.list_element, parent, false);
       return view;
     }

   }

The code fails on the line:

t.setText(st);

with a null pointer exception. The ‘start_time_display’ textview is not being found by the adapter.

The xml file with the field (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>

Which, as you can see, clearly contains teh ‘start_time_display’ text view.

Hopefully I am missing something simple that someone with a bit more experience (I am very new to android and my Java is Tres rusty)

Thanks is advance

Kev

  • 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:19:54+00:00Added an answer on May 16, 2026 at 5:19 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

I have an App that will send authenticated emails using System.Net.Mail and System.Net.NetworkCredential my
I have a Rails app that will post some data to another Rails app.
Does anyone have an XSLT that will take the app.config and render it into
I have an app that needs to open a new window (in the same
I have an app that executes commands on a Linux server via SSH just
I have a app that I'm deploying to a development server using Capistrano. I'd
I have an app that is failing on the install. The vendor says I
I have an app that needs to handle very large strings between a SQL
I have an app that I'm writing a little wizard for. It automated a
I have an app that lets the user search over a number of fields

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.