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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T09:07:20+00:00 2026-05-23T09:07:20+00:00

My class extends SimpleCursorAdapter. In that class I try to get CallLog into ListView

  • 0

My class extends SimpleCursorAdapter. In that class I try to get CallLog into ListView (with three TextViews (number, name and date) and two ImageViews (which represents incoming and outgoing calls).

My code in OnCreate method:

    Cursor c = getContentResolver().query(android.provider.CallLog.Calls.CONTENT_URI, null, "TYPE IN (\"1\",\"2\")", null, "DATE DESC");
    startManagingCursor(c);

    String[] from = new String[] {"number", "name" , "_ID" };
    int[] to = new int[] {R.id.number, R.id.name, R.id.duration};
    listNotImported=(ListView)findViewById(R.id.ListOfNotImportedCalls);
    listNotImported.setOnItemClickListener(this);
    list1Adapter5 = new IconicAdapter5(this, R.layout.rownotimportedcalls, c, from, to);
    listNotImported.setAdapter(list1Adapter5);

My class:

class IconicAdapter5 extends SimpleCursorAdapter
{


    public IconicAdapter5(Context context, int layout, Cursor c, String[] from, int[] to) 
    {
        super(context, layout, c, from, to);
    }
    public View newView(Context context, Cursor c, ViewGroup parent )
    {
        rowNotImported = super.newView(CallLog.this, c, parent);
        String duration= c.getString(c.getColumnIndex("DURATION"));
        ((TextView)rowNotImported.findViewById(R.id.duration)).setText(duration);
        return (rowNotImported);
}

Columns “number”, “name” , “_ID” works fine, everything is ok. but duration, and another columns, which I try to get from cursor (eg “duration”) in newView method are shifting.
jwei512 from ThinkAndroid blog ( http://thinkandroid.wordpress.com/2010/01/11/custom-cursoradapters/ ) wrote about that, but I still dont understand how I can put into my view calculated columns, and another columns in newView method.

I’m confused, because I can not find solution on the internet.Please help me.

jwei512:
“Then you’ll notice some weird behavior – namely, that you’ll see the names start shifting as you scroll up and down the list. What happens is that if you don’t instantiate and place something into your TextView (basically to act as a place holder) then in your bindView method nothing gets bound to some of the TextViews and thus the shifting. So basically, if you see stuff shifting around in your lists, then that’s a big flag for make sure you are binding things to all of your views in both your newView and bindView methods.”

XML representing my row:

    <TableLayout android:layout_alignParentLeft="true" 
    android:layout_alignBaseline="@+id/myTable" android:id="@+id/myTable"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentTop="true"
    android:stretchColumns="0"
    android:shrinkColumns="yes">


    <TableRow>

    <TextView
    android:id="@+id/name"
    android:textSize="18dp"
    android:textColor="@color/white"
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content">
    </TextView>

    <ImageView  
    android:layout_width="20dp" 
    android:layout_height="20dp" 
    android:id="@+id/imageViewType">
    </ImageView>

    </TableRow>




    <TableRow>
    <LinearLayout>
    <TextView
    android:id="@+id/headerNumber"
    android:textColor="@color/white" 
    android:textSize="12sp" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content">
    </TextView>


    <TextView 
    android:id="@+id/number"
    android:textColor="@color/white" 
    android:textSize="12dp" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content"
    android:layout_marginLeft="5dip"
    >
    </TextView>
    </LinearLayout>
    </TableRow>

        <TableRow>
    <LinearLayout>
    <TextView
    android:id="@+id/headerDate"
    android:textColor="@color/white" 
    android:textSize="12dp" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content">

    </TextView>
    <TextView 
    android:id="@+id/date"
    android:textColor="@color/white" 
    android:textSize="12dp" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content"
    android:layout_marginLeft="5dip" >
    </TextView>

    </LinearLayout>
    </TableRow>


    <TableRow>
    <LinearLayout>
    <TextView
    android:id="@+id/headerDuration"
    android:textColor="@color/white" 
    android:textSize="12dp" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content">

    </TextView>
    <TextView 
    android:id="@+id/duration"
    android:textColor="@color/white" 
    android:textSize="12dp" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content"
    android:layout_marginLeft="5dp" >
    </TextView>

    </LinearLayout>
    </TableRow>



    </TableLayout>

  • 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-23T09:07:21+00:00Added an answer on May 23, 2026 at 9:07 am

    I don’t know if I really unerstand you question, but convinient place to make all calculations is overriden method setViewText()

    private class MyCursorAdapter extends SimpleCursorAdapter {
    
    
    
        private Date d = new Date();
    
        @Override
        public void setViewText(TextView v, String text) {
            if (v.getId() == R.id.TrackTime) {
                d.setTime(Long.parseLong(text));
                text = d.toLocaleString();
            }
            super.setViewText(v, text);
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My class extends View and I need to get continuous touch events on it.
Suppose class B extends class A . I have a List<A> that I happen
My Custom Adapter that extends SimpleCursorAdapter for my ListFragment does not display the items
I'm developing a ListView in an Android Fragment. The class extends ListFragment. I tried
I have: One MyListActivity class extends ListActivity setContentView(R.layout.mylist) ; Two xml files: mylist.xml and
Android-newbie playing around with a SimpleCursorAdapter and I've run into a few problems that
class Scr extends MainScreen { public Scr() { TableLayoutManager outerTable = new TableLayoutManager(new int[]
class A extends ApiClass { public void duplicateMethod() { } } class B extends
Button class: class SubmitButton extends JButton implements ActionListener { public SubmitButton(String title){ super(title); ....
class A{ A(int x){} } class B extends A{ B(int x){} public static void

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.