Here is more one link that should help you:

http://blog.cluepusher.dk/2009/11/16/creating-a-custom-cursoradapter-for-android/

09.12.2010 10:09, pramod.deore пишет:
Hi, I am developing one small application to understand how
CursorAdapter works. In this application I have a main activity in
taht I am showing some buttons, after click on "showlist" button
another activity named as ShowSwitchesList is called it is extended
from CursorAdapter.  Now in this class I want to read the database and
display 2 columns from that table to list. If suppose in my list.xml
file i have 2 textview ,but when I write like this then I got error as
R.id.item cannot be resolved.

I am confused where to put setContentView(R.layout.list);  My code is
like this
public class ShowSwitchesList extends CursorAdapter
{
        String SAMPLE_DBNAME = "NewHomeAutoDataBase";
        private final String LOADTYPE_TABLE_NAME = "LoadTable";
        SQLiteDatabase sampleDB = null;

        private Cursor mCursor;
     private Context mContext;
     private final LayoutInflater mInflater;



        public ShowSwitchesList(Context context, Cursor c)
        {
                super(context, c,true);
                // TODO Auto-generated constructor stub
                mInflater = LayoutInflater.from(context);
            mContext = context;

        }

        @Override
        public void bindView(View view, Context context, Cursor cursor)
        {
                final LayoutInflater inflater = LayoutInflater.from(context);
                // TODO Auto-generated method stub
                Cursor c = sampleDB.rawQuery("SELECT SwitchName,LoadType FROM "
+LOADTYPE_TABLE_NAME , null);
                String st = c.getString(c.getColumnIndex("SwitchName"));

                TextView t = (TextView) view.findViewById(R.id.item); //here I 
got
error
        }

        @Override
        public View newView(Context context, Cursor cursor, ViewGroup parent)
        {
                // TODO Auto-generated method stub
                return null;

        }

}

I had not written whole logic yet.



--
Kostya Vasilyev -- WiFi Manager + pretty widget -- http://kmansoft.wordpress.com

--
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