Custom CursorAdapter problem

i have a custom CursorAdapter that populates a list view from a database. my problem is that the list view never shows the last entry i made in the database. it always shows the one before the last and for some reason when i scroll down the list, the first entry i made to the database, is always the last entry too. i don't know if its just the emulator or something else. please here is the main code for the customised CursorAdapter. thank you

private void fillData() { Cursor c = adapter.retrieveItems(); startManagingCursor(c); String[] from = new String[]{DBAdapter.NAME, DBAdapter.START_DATE, DBAdapter.START_TIME}; int[] to = new int[]{R.id.viewNameId, R.id.viewDateId, R.id.viewTimeId, }; customCursorAdapter items = new customCursorAdapter(this, R.layout.view_items, c,from, to); setListAdapter(items); } public class customCursorAdapter extends SimpleCursorAdapter { private int layout; Context context; public customCursorAdapter(Context context, int layout, Cursor c, String[]from, int[] to) { super(context, layout, c, from, to); this.layout = layout; this.context = context; } @Override public void bindView(View view, Context context, Cursor c) { int namecol = c.getColumnIndex(DBAdapter.NAME); String name = c.getString(namecol); TextView viewItemName = (TextView)findViewById(R.id.viewNameId); if(viewItemName != null){ viewItemName.setText(name); viewItemName.setTextColor(Color.RED); } } @Override public View newView(Context context, Cursor cursor, ViewGroup parent) { LayoutInflater inflater = LayoutInflater.from(context); final View view = inflater.inflate(layout, parent, false); return view; } }

Category:android Views:0 Time:2010-08-27
Tags: android

Related post

  • ViewHolder pattern correctly implemented in custom CursorAdapter? 2010-12-31

    Here is my custom CursorAdapter: public class TasksAdapter extends CursorAdapter implements Filterable { private final Context context; public TasksAdapter(Context context, Cursor c) { super(context, c); this.context = context; } /** * @see android.w

  • Make a ListView row clickable using a custom CursorAdapter 2011-01-24

    I am using a Custom CursorAdapter that overrides newView() and bindView() to show a custom ListView. I am inflating the row layout xml file and binding a OnClickListener to the view passed as argument to bindView(): public void bindView(View view, Co

  • How would I use a different row layout in custom CursorAdapter based on Cursor data? 2011-06-04

    Background: I'm trying to implement a messenging system in my app, and I'm writing a custom CursorAdapter to display the messages in a ListView in the chat window. I want to use a different row layout for incoming and outgoing messages (information t

  • Update a custom CursorAdapter from within itself without requery() 2011-11-10

    I have a listView that is populated buy a custom CursorAdapter. I have a button on each row, that when clicked, toggles a value in the database and changes the icon view. The listener for that button is added in the bindView method. The problem is, w

  • ListView with custom CursorAdapter doesn't work well 2012-02-16

    In a part of my android application I have a ListView that shows list of entries in a table. When user tap on a ListView item a new Intent for this item is shown. In the new intent user can do some operations on this entry as reading, editing, favori

  • Is this custom CursorAdapter for a ListView properly coded for Android? 2012-02-24

    I have never been happy with the code on my custom CursorAdapter until today I decided to review it and fix a little problem that was bothering me for a long time (interestingly enough, none of the users of my app ever reported such a problem). Here'

  • Updating a custom CursorAdapter performing a request inside getView fails 2012-03-28

    I'm still not getting exactly how a custom CursorAdapter should work, so after hard tries, here is the thing : I implement a listener on a button inside my getView(). The listener launches a delete row event. To get to it, I use a singleton database

  • I'm facing a runtime custom error problem on server 2011-04-20

    I'm facing a custom error problem on server.can u plz help me out Runtime Error Description: An application error occurred on the server. The current custom error settings for this application prevent the details of the application error from being v

  • Custom CursorAdapter without compatibility package 2012-02-19

    I'm trying to get a custom CursorAdapter working properly. My code currently seems to work well. But based on the Android docs I'm afraid it may be wrong in subtle ways. public class MyArrayAdapter extends CursorAdapter { public MyArrayAdapter(Activi

  • Why does my ListView managed by a custom CursorAdapter refreshes automatically with new data? 2012-02-23

    I have had this "issue" for sometime on my app and it always bothered me that I didn't understand it's behavior, but never cared about asking why, until now. I have a ListView (implemented through a ListActivity) with a custom layout for each list it

  • Problem with "Finalizing Cursor" error in custom CursorAdapter 2010-09-07

    I have a cursor adapter and the logcat is filled with above errors, as soon as I click on a view. I am already releasing the CursorAdapter's cursor in onDestroy(). Is there any way to get information about when the cursor was opened? --------------So

  • sIFR in list-items with custom bullets problem in IE 2009-07-14

    I have a design where sIFR is needed for a vertical menu. With sIFR I replace li-items (with nested lists). In my CSS I have turned off the bullets but for some of the list-items I have made custom bullets with the well-known background-image and pad

  • Flex Custom Component problem 2009-07-28

    I've made a custom component based on MenuBar. This is the code <?xml version="1.0" encoding="utf-8"?> <mx:MenuBar xmlns:mx="http://www.adobe.com/2006/mxml" width="100%" labelField="@label"> <mx:XMLList> <menuitem label="Website"

  • Zen Cart Custom Template Problem 2009-09-15

    I have been asked to upload a Zen Cart site to my servers and have done so fine. I am getting a problem now with the fact that the client has uploaded his custom template into the includes/templates folder and selected it in the admin - but it still

  • Wpf Custom Control problem 2010-01-07

    I have strange problem with WPF custom control that I have made. When I drag and drop WPF custom control from toolbox to design surface I only see one border without any controls in it... I have another same WPF custom control project with same custo

  • JSF - custom component, problem with expression for attribute 2010-03-10

    I want to create custom component with attribute "title" that can have expression but I get this error: Unable to convert string "#{myBean.text}" to class "javax.el.ValueExpression" for attribute "title": Property Editor not registered with the Prope

  • Wordpress - related posts by custom taxonomy problem 2010-06-08

    I'm trying to display related posts based on a custum taxonomy. I found a query at wordpress.org that kind of works. However the original post gets duplicated in the results multiple times. (words is the name of the custom taxonomy I use) What seems

  • GetView Vs. BindView in a custom CursorAdapter? 2010-08-20

    So, I'm watching this video http://www.youtube.com/watch?v=N6YdwzAvwOA and Romain Guy is showing how to make more efficient UI adapter code using the getView() method. Does this apply to CursorAdapters as well? I'm currently using bindView() and newV

  • C++ QList inheritance custom method problem 2010-09-04

    I am creating a custom QList of type Account* called AccountList through inheritance. My interface declaration for AccountList is as follows: class Client { public: Client(QString firstName, QString lastName, QString address1, QString address2, QStri

Copyright (C) dskims.com, All Rights Reserved.

processed in 0.158 (s). 11 q(s)