예제 #1
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            SetContentView(Resource.Layout.HomeScreen);
            listView = FindViewById<ListView>(Resource.Id.List);

            // create the cursor
            vdb = new VegetableDatabase(this);
            cursor = vdb.ReadableDatabase.RawQuery("SELECT * FROM vegetables", null);
            StartManagingCursor(cursor);

            // create the CursorAdapter
            listView.Adapter = (IListAdapter)new HomeScreenCursorAdapter(this, cursor, false);

            listView.ItemClick += OnListItemClick;
        }
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            SetContentView(Resource.Layout.HomeScreen);
            listView = FindViewById <ListView>(Resource.Id.List);

            // create the cursor
            vdb    = new VegetableDatabase(this);
            cursor = vdb.ReadableDatabase.RawQuery("SELECT * FROM vegetables", null);
            StartManagingCursor(cursor);

            // create the CursorAdapter
            listView.Adapter = (IListAdapter) new HomeScreenCursorAdapter(this, cursor, false);

            listView.ItemClick += OnListItemClick;
        }
예제 #3
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            SetContentView(Resource.Layout.HomeScreen);
            listView = FindViewById<ListView>(Resource.Id.List);

            // create the cursor
            vdb = new VegetableDatabase(this);
            cursor = vdb.ReadableDatabase.RawQuery("SELECT * FROM vegetables", null);
            StartManagingCursor(cursor);

            // which columns map to which layout controls
            string[] fromColumns = new string[] { "name" };
            int[] toControlIds = new int [] {Android.Resource.Id.Text1};

            // use a SimpleCursorAdapter
            listView.Adapter = new SimpleCursorAdapter(this, Android.Resource.Layout.SimpleListItem1, cursor, fromColumns, toControlIds);

            listView.ItemClick += OnListItemClick;
        }
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            SetContentView(Resource.Layout.HomeScreen);
            listView = FindViewById <ListView>(Resource.Id.List);

            // create the cursor
            vdb    = new VegetableDatabase(this);
            cursor = vdb.ReadableDatabase.RawQuery("SELECT * FROM vegetables", null);
            StartManagingCursor(cursor);

            // which columns map to which layout controls
            string[] fromColumns  = new string[] { "name" };
            int[]    toControlIds = new int [] { Android.Resource.Id.Text1 };

            // use a SimpleCursorAdapter
            listView.Adapter = new SimpleCursorAdapter(this, Android.Resource.Layout.SimpleListItem1, cursor, fromColumns, toControlIds);

            listView.ItemClick += OnListItemClick;
        }
예제 #5
0
        public override Android.Net.Uri Insert(Android.Net.Uri uri, ContentValues values)
        {
            Android.Util.Log.Debug("Test", "Insert");
            //---add a new book---
            _s_DB = new VegetableDatabase(this.Context);
            var _database = _s_DB.WritableDatabase;

            _database.BeginTransaction();
            long rowID = _database.Insert(DATABASE_TABLE, "", values);

            //---if added successfully---
            if (rowID > 0)
            {
                var _uri = ContentUris.WithAppendedId(CONTENT_URI, rowID);
                Context.ContentResolver.NotifyChange(_uri, null);
                _database.SetTransactionSuccessful();
                _database.EndTransaction();
                return(_uri);
            }
            throw new SQLException("Failed to insert row into " + uri);
            //throw new NotImplementedException(); //Java.Lang.UnsupportedOperationException();
        }
 public override bool OnCreate()
 {
     vegeDB = new VegetableDatabase(Context);
     return true;
 }
예제 #7
0
 public override bool OnCreate()
 {
     vegeDB = new VegetableDatabase(Context);
     return(true);
 }