Thanks mate, I actually ended implementing something like that
(although it seems I don't need HistoryCursorAdapter and newView
methods (?)).

private class MyAdapter extends ResourceCursorAdapter {
        public MyAdapter(Context context, Cursor cur) {
                super(context, R.layout.todo_multi_row, cur);
        }

        @Override
        public void bindView(View view, Context context, Cursor cur) {
                final int textIndex =
cur.getColumnIndexOrThrow(TodoDbAdapter.KEY_NAME);
            final int checkedIndex =
cur.getColumnIndexOrThrow(TodoDbAdapter.KEY_CHECKED);

                CheckedTextView item = (CheckedTextView) view;
            item.setText(cur.getString(textIndex));
            boolean selected = (cur.getInt(checkedIndex) > 0 ? true :
false);
            item.setChecked(selected);

            //called too many times.. but anyways..
            //Log.d("LIST", "binding: "+view);
        }
    }

Thing is, it gets called a lot of times for nothing.. but it is not a
problem.
Another issue I have is that when I edit something on the list I have
to do a requery().. meaning, if I check a box, I change the SQLite
Database and then to see the change in the view I have to do a
requery() to reload the cursor.. which is not really the best
solution.. but I couldn't find anything else :D

Anyway, further infos here:
http://stackoverflow.com/questions/4974927/android-listview-of-checkedtextview-sqlite-display-checked-rows-with-adapter

- Stefano

On Feb 12, 2:33 pm, Rutton <rut...@web.de> wrote:
> If you have done a cursor adapter once, itis really easy.
> I have put some example code here. It is stripped down
> to the essentials:
>
> public class HistoryCursorAdapter extends CursorAdapter {
>         private Cursor cursor;
>
>         public HistoryCursorAdapter(Context context, Cursor c) {
>                 super(context, c);
>                 cursor = c;
>         }
>
>         @Override
>         public void bindView(View view, Context context, Cursor cursor) {
>                  TextView tvSearchString = (TextView)
> view.findViewById( R.id.search_string );
>                    // this search_string_view must be part of the
> layout created in newView.
>
>                  String searchString =
> cursor.getString( cursor.getColumnIndex( HistoryProvider.SEARCH_STRING));
>                  tvSearchString.setText( searchString );
>         }
>
>         @Override
>         public View newView(Context context, Cursor cursor, ViewGroup parent)
> {
>                 LayoutInflater li =
> (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
>                 return li.inflate( R.layout.<put_your_listitem_layout_here>, 
> parent,
> false );
>         }
>
>
>
>
>
>
>
> }

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to