/// <inheritdoc/> public override void OnActivityResult(int requestCode, int resultCode, Intent data) { ZTnTrace.Trace(MethodBase.GetCurrentMethod()); switch (requestCode) { case AddNewAccount: switch (resultCode) { case -1: var battleTag = data.GetStringExtra("battleTag"); var host = data.GetStringExtra("host"); D3Context.Instance.DbAccounts.Insert(battleTag, host); IListAdapter careerAdapter = new SimpleCursorAdapter(Activity, Android.Resource.Layout.SimpleListItem2, cursor, accountsFromColumns, accountsToId); Activity.FindViewById<ListView>(Resource.Id.AccountsListView) .Adapter = careerAdapter; Toast.MakeText(Activity, "Account added", ToastLength.Short) .Show(); break; } break; } base.OnActivityResult(requestCode, resultCode, data); }
void ShowResults(string query) { var cursor = ManagedQuery(DictionaryProvider.CONTENT_URI, null, null, new string[] { query }, null); if (cursor == null) { // There are no results textView.Text = GetString(Resource.String.no_results, query); } else { int count = cursor.Count; var countString = Resources.GetQuantityString(Resource.Plurals.search_results, count, count, query); textView.Text = countString; string[] from = new string[] { DictionaryDatabase.KEY_WORD, DictionaryDatabase.KEY_DEFINITION }; int[] to = new int[] { Resource.Id.word, Resource.Id.definition }; var words = new SimpleCursorAdapter(this, Resource.Layout.result, cursor, from, to); listView.SetAdapter(words); listView.ItemClick += (sender, e) => { var wordIntent = new Intent(ApplicationContext, typeof(WordActivity)); var data = Android.Net.Uri.WithAppendedPath(DictionaryProvider.CONTENT_URI, Java.Lang.String.ValueOf(e.Id)); wordIntent.SetData(data); StartActivity(wordIntent); }; } }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); SetContentView(Resource.Layout.HomeScreen); listView = FindViewById<ListView>(Resource.Id.List); string[] projection = new string[] { VegetableProvider.InterfaceConsts.Id, VegetableProvider.InterfaceConsts.Name }; string[] fromColumns = new string[] { VegetableProvider.InterfaceConsts.Name }; int[] toControlIds = new int[] { Android.Resource.Id.Text1 }; // ManagedQuery is deprecated in Honeycomb (3.0, API11) cursor = ManagedQuery(VegetableProvider.CONTENT_URI, projection, null, null, null); // ContentResolver requires you to close the query yourself //cursor = ContentResolver.Query(VegetableProvider.CONTENT_URI, projection, null, null, null); //StartManagingCursor(cursor); // CursorLoader introduced in Honeycomb (3.0, API11) var loader = new CursorLoader(this, VegetableProvider.CONTENT_URI, projection, null, null, null); cursor = (ICursor)loader.LoadInBackground(); // create a SimpleCursorAdapter adapter = new SimpleCursorAdapter(this, Android.Resource.Layout.SimpleListItem1, cursor, fromColumns, toControlIds); listView.Adapter = adapter; listView.ItemClick += OnListItemClick; }
public override void OnActivityCreated(Bundle savedInstanceState) { base.OnActivityCreated(savedInstanceState); // In this sample we are going to use a retained fragment. SetRetainInstance(true); // Give some text to display if there is no data. In a real // application this would come from a resource. SetEmptyText("No phone numbers"); // We have a menu item to show in action bar. SetHasOptionsMenu(true); // Create an empty adapter we will use to display the loaded data. mAdapter = new SimpleCursorAdapter(GetActivity(), global::Android.R.Layout.Simple_list_item_1, null, new string[] { Contacts.IPeopleColumnsConstants.DISPLAY_NAME }, new int[] { global::Android.R.Id.Text1 }, 0); SetListAdapter(mAdapter); // Start out with a progress indicator. SetListShown(false); // Prepare the loader. Either re-connect with an existing one, // or start a new one. GetLoaderManager().InitLoader(0, null, this); }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); SetContentView(Resource.Layout.HomeScreen); listView = FindViewById <ListView>(Resource.Id.List); string[] projection = new string[] { VegetableProvider.InterfaceConsts.Id, VegetableProvider.InterfaceConsts.Name }; string[] fromColumns = new string[] { VegetableProvider.InterfaceConsts.Name }; int[] toControlIds = new int[] { Android.Resource.Id.Text1 }; // ManagedQuery is deprecated in Honeycomb (3.0, API11) cursor = ManagedQuery(VegetableProvider.CONTENT_URI, projection, null, null, null); // ContentResolver requires you to close the query yourself //cursor = ContentResolver.Query(VegetableProvider.CONTENT_URI, projection, null, null, null); //StartManagingCursor(cursor); // CursorLoader introduced in Honeycomb (3.0, API11) var loader = new CursorLoader(this, VegetableProvider.CONTENT_URI, projection, null, null, null); cursor = (ICursor)loader.LoadInBackground(); // create a SimpleCursorAdapter adapter = new SimpleCursorAdapter(this, Android.Resource.Layout.SimpleListItem1, cursor, fromColumns, toControlIds); listView.Adapter = adapter; listView.ItemClick += OnListItemClick; }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); SetContentView(Resource.Layout.gallery_2); // Get a cursor with all people ICursor c = ContentResolver.Query(ContactsContract.Contacts.ContentUri, CONTACT_PROJECTION, null, null, null); StartManagingCursor(c); var adapter = new SimpleCursorAdapter(this, // Use a template that displays a text view Android.Resource.Layout.SimpleGalleryItem, // Give the cursor to the list adatper c, // Map the NAME column in the people database to... new String[] { ContactsContract.Contacts.InterfaceConsts.DisplayName }, // The "text1" view defined in the XML template new int[] { Android.Resource.Id.Text1 }); Gallery g = FindViewById <Gallery> (Resource.Id.gallery); g.Adapter = adapter; }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); SetContentView(Resource.Layout.history); _historyDataHelper = new HistoryDataHelper(this); ListAdapter = new SimpleCursorAdapter(this, Resource.Layout.history_item, getHistory(), new string[] { "Title" }, new int[] { Resource.Id.page_title }); }
protected override void OnCreate (Bundle bundle) { base.OnCreate (bundle); // Get a cursor with all people ICursor c = ContentResolver.Query (ContactsContract.Contacts.ContentUri, CONTACT_PROJECTION, null, null, null); StartManagingCursor (c); var adapter = new SimpleCursorAdapter (this, Android.Resource.Layout.SimpleListItem1, c, new String[] {ContactsContract.Contacts.InterfaceConsts.DisplayName}, new int[] {Android.Resource.Id.Text1}); ListAdapter = adapter; }
// Populate the contact list based on account currently selected in the account spinner. private void PopulateContactList() { // Build adapter with contact entries ICursor cursor = GetContacts(); string[] fields = new string[] { ContactsContract.ContactsColumns.DisplayName }; SimpleCursorAdapter adapter = new SimpleCursorAdapter(this, Resource.Layout.ContactEntry, cursor, fields, new int[] { Resource.Id.contactEntryText }); contact_list.Adapter = adapter; }
// Populate the contact list based on account currently selected in the account spinner. private void PopulateContactList () { // Build adapter with contact entries ICursor cursor = GetContacts (); string[] fields = new string[] { ContactsContract.ContactsColumnsConsts.DisplayName }; SimpleCursorAdapter adapter = new SimpleCursorAdapter (this, Resource.Layout.ContactEntry, cursor, fields, new int[] { Resource.Id.contactEntryText }); contact_list.Adapter = adapter; }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); // Get a cursor with all people ICursor c = ContentResolver.Query(ContactsContract.Contacts.ContentUri, CONTACT_PROJECTION, null, null, null); StartManagingCursor(c); var adapter = new SimpleCursorAdapter(this, Android.Resource.Layout.SimpleListItem1, c, new String[] { ContactsContract.Contacts.InterfaceConsts.DisplayName }, new int[] { Android.Resource.Id.Text1 }); ListAdapter = adapter; }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); // Set our view from the "main" layout resource SetContentView(Resource.Layout.CalendarList); // List Calendars var calendarsUri = CalendarContract.Calendars.ContentUri; string[] calendarsProjection = { CalendarContract.Calendars.InterfaceConsts.Id, CalendarContract.Calendars.InterfaceConsts.CalendarDisplayName, CalendarContract.Calendars.InterfaceConsts.AccountName }; var loader = new CursorLoader(this, calendarsUri, calendarsProjection, null, null, null); var cursor = (ICursor)loader.LoadInBackground(); string[] sourceColumns = { CalendarContract.Calendars.InterfaceConsts.CalendarDisplayName, CalendarContract.Calendars.InterfaceConsts.AccountName }; int[] targetResources = { Resource.Id.calDisplayName, Resource.Id.calAccountName }; SimpleCursorAdapter adapter = new SimpleCursorAdapter(this, Resource.Layout.CalListItem, cursor, sourceColumns, targetResources); ListAdapter = adapter; ListView.ItemClick += (sender, e) => { int i = (e as Android.Widget.AdapterView.ItemClickEventArgs).Position; cursor.MoveToPosition(i); int calId = cursor.GetInt(cursor.GetColumnIndex(calendarsProjection [0])); var showEvents = new Intent(this, typeof(EventListActivity)); showEvents.PutExtra("calId", calId); StartActivity(showEvents); }; }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SQLiteOpenHelper recipeBookHelper = new RecipeBookSQLHelper(this); db = recipeBookHelper.ReadableDatabase; cursor = db.Query("RECIPE", new string[] { "_id, NAME" }, null, null, null, null, null); CursorAdapter recipes = new SimpleCursorAdapter(this, Android.Resource.Layout.SimpleListItem1, cursor, new string[] { "NAME" }, new int[] { Android.Resource.Id.Text1 }, 0); ListAdapter = recipes; ListView.ItemClick += (object sender, AdapterView.ItemClickEventArgs e) => { Intent intent = new Intent(this, typeof(RecipeActivity)); intent.PutExtra(RecipeActivity.EXTRA_RECIPE_NUM, e.Position); StartActivity(intent); }; ListView.ItemLongClick += (object sender, AdapterView.ItemLongClickEventArgs e) => { //Toast.MakeText(this, ListAdapter.GetItem(e.Position).ToString(), ToastLength.Short).Show(); // create ingredient fragment so ingredients can be previewed FragmentTransaction ft = FragmentManager.BeginTransaction(); Fragment prev = FragmentManager.FindFragmentByTag("dialog"); if (prev != null) { ft.Remove(prev); } ft.AddToBackStack(null); Bundle strings = new Bundle(); int recipeNumber = e.Position; cursor = db.Query("RECIPE", new string[] { "NAME", "INGREDIENTS", "DIRECTIONS" }, "_id = ?", new string[] { (++recipeNumber).ToString() }, null, null, null); if (cursor.MoveToFirst()) { strings.PutString("RName", cursor.GetString(0)); strings.PutString("RIngredients", cursor.GetString(1)); } IngredientsDialog newFragment = IngredientsDialog.NewInstance(strings); newFragment.Show(ft, "dialog"); }; }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); Intent intent = Intent; Uri uri = null; String query = null; if (Intent.ActionSearch.Equals(intent.Action)) { query = intent.GetStringExtra(SearchManager.Query); } else if (bundle != null) { query = bundle.GetString(SearchManager.Query); } if (query != null && query.Length > 0) { uri = Uri.WithAppendedPath(WikiNote.Notes.SEARCH_URI, Uri.Encode(query)); } if (uri == null) { // somehow we got called w/o a query so fall back to a reasonable // default (all notes) uri = WikiNote.Notes.ALL_NOTES_URI; } // Do the query ICursor c = ManagedQuery(uri, WikiNote.WIKI_LISTNOTES_PROJECTION, null, null, WikiNote.Notes.BY_TITLE_SORT_ORDER); _cursor = c; _helper = new WikiActivityHelper(this); // Bind the results of the search into the list ListAdapter = new SimpleCursorAdapter( this, Android.Resource.Layout.SimpleListItem1, _cursor, new String[] { WikiNote.Notes.TITLE }, new int[] { Android.Resource.Id.Text1 }); SetDefaultKeyMode(DefaultKey.Shortcut); }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); // Set our view from the "main" layout resource SetContentView(Resource.Layout.OneView); // List Calendars var calendarsUri = CalendarContract.Calendars.ContentUri; // Select columns names to be searched _calendarsProjection = new[] { CalendarContract.Calendars.InterfaceConsts.Id, CalendarContract.Calendars.InterfaceConsts.CalendarDisplayName, CalendarContract.Calendars.InterfaceConsts.AccountName }; // Create database query _cursor = ManagedQuery(calendarsUri, _calendarsProjection, null, null, null); // Select columns names to be searched string[] sourceColumns = { CalendarContract.Calendars.InterfaceConsts.CalendarDisplayName, CalendarContract.Calendars.InterfaceConsts.AccountName }; // Select columns names to be searched int[] targetResources = { Resource.Id.calDisplayName, Resource.Id.calAccountName }; // List adapter var adapter = new SimpleCursorAdapter(this, Resource.Layout.OneListItem, _cursor, sourceColumns, targetResources); ListAdapter = adapter; ListView.ItemClick += ListView_ItemClick; }
private void Readcontact_Click(object sender, System.EventArgs e) { var uri = ContactsContract.Contacts.ContentUri; contactlist = (ListView)FindViewById(Resource.Id.contactlist); string[] projection = { ContactsContract.Contacts.InterfaceConsts.Id, ContactsContract.Contacts.InterfaceConsts.DisplayName }; var loader = new CursorLoader(this, uri, projection, null, null, null); var cursor = (ICursor)loader.LoadInBackground(); var fromColumns = new string[] { ContactsContract.Contacts.InterfaceConsts.DisplayName }; var toControlIds = new int[] { Android.Resource.Id.Text1 }; adapter = new SimpleCursorAdapter(this, Android.Resource.Layout.SimpleListItem1, cursor, fromColumns, toControlIds); contactlist.Adapter = adapter; }
private void FillData() { ICursor notesCursor = this.dbHelper.FetchAllNotes(); this.StartManagingCursor(notesCursor); // Create an array to specify the fields we want to display in the list (only TITLE) var from = new[] { NotesDbAdapter.KeyTitle }; // and an array of the fields we want to bind those fields to (in this case just text1) var to = new[] { Resource.Id.text1 }; // Now create a simple cursor adapter and set it to display var notes = new SimpleCursorAdapter(this, Resource.Layout.notes_row, notesCursor, from, to); this.ListAdapter = notes; }
private void FillData() { ICursor custCursor = this.dbHelper.FetchAllCusts(); this.StartManagingCursor(custCursor); // Create an array to specify the fields we want to display in the list (only name) var from = new[] { NamaadDbAdapter_note.KeyName }; // and an array of the fields we want to bind those fields to (in this case just recRowTV) var to = new[] { Resource.Id.recRowTV }; // Now create a simple cursor adapter and set it to display var Custs = new SimpleCursorAdapter(this, Resource.Layout.recs_row, custCursor, from, to); this.ListAdapter = Custs; }
void ListEvents() { var eventsUri = CalendarContract.Events.ContentUri; string[] eventsProjection = { CalendarContract.Events.InterfaceConsts.Id, CalendarContract.Events.InterfaceConsts.Title, CalendarContract.Events.InterfaceConsts.Dtstart }; var loader = new CursorLoader(this, eventsUri, eventsProjection, String.Format("calendar_id={0}", _calId), null, "dtstart ASC"); var cursor = (ICursor)loader.LoadInBackground(); string[] sourceColumns = { CalendarContract.Events.InterfaceConsts.Title, CalendarContract.Events.InterfaceConsts.Dtstart }; int[] targetResources = { Resource.Id.eventTitle, Resource.Id.eventStartDate }; var adapter = new SimpleCursorAdapter(this, Resource.Layout.EventListItem, cursor, sourceColumns, targetResources); adapter.ViewBinder = new ViewBinder(); ListAdapter = adapter; // ListView.ItemClick += (sender, e) => { // int i = (e as ItemEventArgs).Position; // // cursor.MoveToPosition(i); // int eventId = cursor.GetInt (cursor.GetColumnIndex (eventsProjection [0])); // var uri = ContentUris.WithAppendedId(CalendarContract.Events.ContentUri, eventId); // var intent = new Intent(Intent.ActionView, uri); // StartActivity(intent); // }; }
protected override void OnCreate (Bundle bundle) { base.OnCreate (bundle); // Get a cursor with all phones ICursor c = ContentResolver.Query (ContactsContract.CommonDataKinds.Phone.ContentUri, PHONE_PROJECTION, null, null, null); StartManagingCursor (c); // Map Cursor columns to views defined in simple_list_item_2.xml var adapter = new SimpleCursorAdapter (this, Android.Resource.Layout.SimpleListItem2, c, new String[] {PhoneType, PhoneNumber}, new int[] { Android.Resource.Id.Text1, Android.Resource.Id.Text2 }); //Used to display a readable string for the phone type adapter.ViewBinder = new SimpleViewBinder (this); ListAdapter = adapter; }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); // Get a cursor with all phones ICursor c = ContentResolver.Query(ContactsContract.CommonDataKinds.Phone.ContentUri, PHONE_PROJECTION, null, null, null); StartManagingCursor(c); // Map Cursor columns to views defined in simple_list_item_2.xml var adapter = new SimpleCursorAdapter(this, Android.Resource.Layout.SimpleListItem2, c, new String[] { PhoneType, PhoneNumber }, new int[] { Android.Resource.Id.Text1, Android.Resource.Id.Text2 }); //Used to display a readable string for the phone type adapter.ViewBinder = new SimpleViewBinder(this); ListAdapter = adapter; }
public void CreateEvent() { AndroidCalendar userCalendar = new AndroidCalendar(); string[] sourceColumns = { CalendarContract.Events.InterfaceConsts.Title, CalendarContract.Events.InterfaceConsts.Dtstart }; int[] targetResources = { Resource.Id.goalTitle, Resource.Id.startDate }; var adapter = new SimpleCursorAdapter(this, Resource.Layout.Main, userCalendar.GetEventIcursor(userCalendar.GetEventsUri(), userCalendar.GetUserCalendarEvents(), 0), sourceColumns, targetResources); IListAdapter ListAdapter = adapter; }
protected override void OnCreate (Bundle bundle) { base.OnCreate (bundle); SetContentView (Resource.Layout.list_7); mPhone = FindViewById <TextView> (Resource.Id.phone); ListView.ItemClick += List7ItemSelected; // Get a cursor with all numbers. // This query will only return contacts with phone numbers ICursor c = ContentResolver.Query (ContactsContract.CommonDataKinds.Phone.ContentUri, PHONE_PROJECTION, ContactsContract.CommonDataKinds.Phone.Number + " NOT NULL", null, null); StartManagingCursor(c); var adapter = new SimpleCursorAdapter (this, Android.Resource.Layout.SimpleListItem1, c, new string[] {ContactsContract.CommonDataKinds.Phone.InterfaceConsts.DisplayName}, new int[] {Android.Resource.Id.Text1}); ListAdapter = adapter; }
public override void OnActivityCreated(Bundle savedInstanceState) { base.OnActivityCreated(savedInstanceState); SetEmptyText("No data. Select 'Populate' to fill with data from Z to A at a rate of 4 per second."); SetHasOptionsMenu(true); // Create an empty adapter we will use to display the loaded data. mAdapter = new SimpleCursorAdapter(GetActivity(), global::Android.R.Layout.Simple_list_item_1, null, new string[] { MainTable.COLUMN_NAME_DATA }, new int[] { global::Android.R.Id.Text1 }, 0); SetListAdapter(mAdapter); // Start out with a progress indicator. SetListShown(false); // Prepare the loader. Either re-connect with an existing one, // or start a new one. GetLoaderManager().InitLoader(0, null, this); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); // Set our view from the "main" layout resource SetContentView(Resource.Layout.Main); var cdb = new CountriesDatabase(this); cdb.InitDatabase(); // Para grandes cantidades de datos, es necesario utilizar CursorAdapter var autocompleteTextView = FindViewById <AutoCompleteTextView>(Resource.Id.autoCompleteInput); string[] fromColumns = new string[] { CountriesProvider.InterfaceConsts.Name }; int[] toControls = new int[] { Android.Resource.Id.Text1 }; adapter = new SimpleCursorAdapter(this, Android.Resource.Layout.SimpleDropDownItem1Line, null, fromColumns, toControls); adapter.CursorToStringConverter = new CustomCursorToStringConverter(); adapter.FilterQueryProvider = new CustomFilterQueryProvider(this, 5); autocompleteTextView.Adapter = adapter; }
void BuscarPaisesCoincidan(string query) { var cursor = ManagedQuery(cpProveedorDatos.CONTENT_URI, null, null, new string[] { query }, null); if (cursor == null) { // No se encontraro resultados tv_Mensaje.Text = GetString(Resource.String.no_results, query); } else { int count = cursor.Count; var countString = Resources.GetQuantityString(Resource.Plurals.search_results, count, count, query); tv_Mensaje.Text = countString; string[] from = new string[] { Manejador_db.KEY_PAIS, Manejador_db.KEY_CONTINENTE }; int[] to = new int[] { Resource.Id.tv_Pais, Resource.Id.tv_Continente }; var words = new SimpleCursorAdapter(this, Resource.Layout.item_pais, cursor, from, to); lv_Paises.Adapter = words; } }
//Gets the cursor view to show all records void GetCursorView() { Android.Database.ICursor sqldb_cursor = sqldb.GetRecordCursor(); if (sqldb_cursor != null) { sqldb_cursor.MoveToFirst(); string[] from = new string[] { "_id", "DeliveryId", "CustomerName", "CommitedDeliveryTime" }; int[] to = new int[] { Resource.Id.Id_row, Resource.Id.DeliveryId_row, Resource.Id.CustomerName_row, Resource.Id.CommitedDeliveryTime_row }; //Creates a SimplecursorAdapter for ListView object SimpleCursorAdapter sqldb_adapter = new SimpleCursorAdapter(this, Resource.Layout.record_view, sqldb_cursor, from, to); listItems.Adapter = sqldb_adapter; } else { Toast.MakeText(Application.Context, sqldb.Message, ToastLength.Long).Show(); } }
protected override void OnCreate (Bundle bundle) { base.OnCreate (bundle); // Set our view from the "main" layout resource SetContentView (Resource.Layout.CalendarList); // List Calendars var calendarsUri = CalendarContract.Calendars.ContentUri; string[] calendarsProjection = { CalendarContract.Calendars.InterfaceConsts.Id, CalendarContract.Calendars.InterfaceConsts.CalendarDisplayName, CalendarContract.Calendars.InterfaceConsts.AccountName }; var cursor = ManagedQuery (calendarsUri, calendarsProjection, null, null, null); string[] sourceColumns = {CalendarContract.Calendars.InterfaceConsts.CalendarDisplayName, CalendarContract.Calendars.InterfaceConsts.AccountName}; int[] targetResources = {Resource.Id.calDisplayName, Resource.Id.calAccountName}; SimpleCursorAdapter adapter = new SimpleCursorAdapter (this, Resource.Layout.CalListItem, cursor, sourceColumns, targetResources); ListAdapter = adapter; ListView.ItemClick += (sender, e) => { int i = (e as ItemEventArgs).Position; cursor.MoveToPosition(i); int calId = cursor.GetInt (cursor.GetColumnIndex (calendarsProjection [0])); var showEvents = new Intent(this, typeof(EventListActivity)); showEvents.PutExtra("calId", calId); StartActivity(showEvents); }; }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); SetContentView(Resource.Layout.list_7); mPhone = FindViewById <TextView> (Resource.Id.phone); ListView.ItemClick += List7ItemSelected; // Get a cursor with all numbers. // This query will only return contacts with phone numbers ICursor c = ContentResolver.Query(ContactsContract.CommonDataKinds.Phone.ContentUri, PHONE_PROJECTION, ContactsContract.CommonDataKinds.Phone.Number + " NOT NULL", null, null); StartManagingCursor(c); var adapter = new SimpleCursorAdapter(this, Android.Resource.Layout.SimpleListItem1, c, new string[] { ContactsContract.CommonDataKinds.Phone.InterfaceConsts.DisplayName }, new int[] { Android.Resource.Id.Text1 }); ListAdapter = adapter; }
private void PopulateCustomersList() { ListView listCustomers = FindViewById <ListView>(Resource.Id.listCustomers); // Adatbázis létrehozása vtcDatabase vtcDatabase = new vtcDatabase("ListData"); Android.Database.ICursor cursor = vtcDatabase.GetRecordCursor(); if (cursor != null) { cursor.MoveToFirst(); string[] from = new string[] { "_id", "Nev", "Email", "Telefon" }; int[] to = new int[] { Resource.Id.CustomerID, Resource.Id.CustomerName, Resource.Id.CustomerEmail, Resource.Id.CustomerPhone }; // SimpleCursorAdapter adapter = new SimpleCursorAdapter(this, Resource.Layout.CustomerItem, cursor, from, to); listCustomers.Adapter = adapter; } }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); var calendarsUri = CalendarContract.Calendars.ContentUri; string[] calendarsProjection = { CalendarContract.Calendars.InterfaceConsts.Id, CalendarContract.Calendars.InterfaceConsts.CalendarDisplayName, CalendarContract.Calendars.InterfaceConsts.AccountName }; var cursor = ManagedQuery(calendarsUri, calendarsProjection, null, null, null); string[] sourceColumns = { CalendarContract.Calendars.InterfaceConsts.CalendarDisplayName, CalendarContract.Calendars.InterfaceConsts.AccountName }; int[] targetResources = { Resource.Id.calDisplayName, Resource.Id.calAccountName }; SimpleCursorAdapter adapter = new SimpleCursorAdapter(this, Resource.Layout.CalListItem, cursor, sourceColumns, targetResources); }
protected override void OnCreate (Bundle bundle) { base.OnCreate (bundle); SetContentView (Resource.Layout.gallery_2); // Get a cursor with all people ICursor c = ContentResolver.Query (ContactsContract.Contacts.ContentUri, CONTACT_PROJECTION, null, null, null); StartManagingCursor (c); var adapter = new SimpleCursorAdapter (this, // Use a template that displays a text view Android.Resource.Layout.SimpleGalleryItem, // Give the cursor to the list adatper c, // Map the NAME column in the people database to... new String[] {ContactsContract.Contacts.InterfaceConsts.DisplayName}, // The "text1" view defined in the XML template new int[] { Android.Resource.Id.Text1 }); Gallery g = FindViewById <Gallery> (Resource.Id.gallery); g.Adapter = adapter; }
void ListEvents () { var eventsUri = CalendarContract.Events.ContentUri; string[] eventsProjection = { CalendarContract.Events.InterfaceConsts.Id, CalendarContract.Events.InterfaceConsts.Title, CalendarContract.Events.InterfaceConsts.Dtstart }; var cursor = ManagedQuery (eventsUri, eventsProjection, String.Format ("calendar_id={0}", _calId), null, "dtstart ASC"); string[] sourceColumns = { CalendarContract.Events.InterfaceConsts.Title, CalendarContract.Events.InterfaceConsts.Dtstart }; int[] targetResources = { Resource.Id.eventTitle, Resource.Id.eventStartDate }; var adapter = new SimpleCursorAdapter (this, Resource.Layout.EventListItem, cursor, sourceColumns, targetResources); adapter.ViewBinder = new ViewBinder (); ListAdapter = adapter; // ListView.ItemClick += (sender, e) => { // int i = (e as ItemEventArgs).Position; // // cursor.MoveToPosition(i); // int eventId = cursor.GetInt (cursor.GetColumnIndex (eventsProjection [0])); // var uri = ContentUris.WithAppendedId(CalendarContract.Events.ContentUri, eventId); // var intent = new Intent(Intent.ActionView, uri); // StartActivity(intent); // }; }
private void ListEvents() { var eventsUri = CalendarContract.Events.ContentUri; // Select columns names to be searched string[] eventsProjection = { CalendarContract.Events.InterfaceConsts.Id, CalendarContract.Events.InterfaceConsts.Title, CalendarContract.Events.InterfaceConsts.Dtstart }; // Create database query var cursor = ManagedQuery(eventsUri, eventsProjection, String.Format("calendar_id={0}", _calId), null, "dtstart ASC"); // Select columns names to be searched string[] sourceColumns = { CalendarContract.Events.InterfaceConsts.Title, CalendarContract.Events.InterfaceConsts.Dtstart }; int[] targetResources = { Resource.Id.eventTitle, Resource.Id.eventStartDate }; // Create database query var adapter = new SimpleCursorAdapter(this, Resource.Layout.TwoListItem, cursor, sourceColumns, targetResources); adapter.ViewBinder = new ViewBinder(); ListAdapter = adapter; }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); SetContentView(Resource.Layout.CalendarList); var calendarUri = CalendarContract.Calendars.ContentUri; string[] calendarsProjection = { CalendarContract.Calendars.InterfaceConsts.Id, CalendarContract.Calendars.InterfaceConsts.CalendarDisplayName, CalendarContract.Calendars.InterfaceConsts.AccountName, }; var cursor = ManagedQuery(calendarUri, calendarsProjection, null, null, null); string[] sourceColumns = { CalendarContract.Calendars.InterfaceConsts.CalendarDisplayName, CalendarContract.Calendars.InterfaceConsts.AccountName }; int [] targetResources = { Resource.Id.calDisplayName, Resource.Id.calAccountName }; var adapter = new SimpleCursorAdapter(this, Resource.Layout.CalListItem, cursor, sourceColumns, targetResources); ListAdapter = adapter; ListView.ItemClick += (s, e) => { var i = (e as AdapterView.ItemClickEventArgs).Position; cursor.MoveToPosition(i); var calId = cursor.GetInt(cursor.GetColumnIndex(calendarsProjection[0])); var showEvents = new Intent(this, typeof(EventListActivity)); showEvents.PutExtra("calId", calId); StartActivity(showEvents); }; }
private void FillData() { // Get all of the rows from the database and create the item list ICursor filesCursor = _dbHelper.FetchAllFiles(); StartManagingCursor(filesCursor); // Create an array to specify the fields we want to display in the list // (only TITLE) String[] from = new[] { FileDbHelper.KeyFileFilename }; // and an array of the fields we want to bind those fields to (in this // case just text1) int[] to = new[] { Resource.Id.file_filename }; // Now create a simple cursor adapter and set it to display SimpleCursorAdapter recentFilesAdapter = new SimpleCursorAdapter(this, Resource.Layout.file_row, filesCursor, from, to); recentFilesAdapter.ViewBinder = new MyViewBinder(App.Kp2a); FragmentManager.FindFragmentById <RecentFilesFragment>(Resource.Id.recent_files).SetAdapter(recentFilesAdapter); }
private void FillData() { ICursor notesCursor = this.dbHelper.FetchAllFavorites(); Activity.StartManagingCursor(notesCursor); // Create an array to specify the fields we want to display in the list (only TITLE) var from = new[] { NotesDbAdapter.KeyScriptureTitle, NotesDbAdapter.KeyTitle }; // and an array of the fields we want to bind those fields to (in this case just text1) var to = new[] { Resource.Id.textNoteTitle, Resource.Id.textNoteContent }; // Now create a simple cursor adapter and set it to display notesAdapter = new SimpleCursorAdapter(Activity, Resource.Layout.NoteRow, notesCursor, from, to); notesAdapter.FilterQueryProvider = new FilterQueryProvider(c => notesCursor, dbHelper); this.ListAdapter = notesAdapter; ICursor cursor = ((SimpleCursorAdapter)ListView.Adapter).Cursor; while (cursor.MoveToNext()) { NoteScripture n = new NoteScripture() { Id = int.Parse(cursor.GetString(cursor.GetColumnIndex(NotesDbAdapter.KeyRowId))), Title = cursor.GetString(cursor.GetColumnIndex(NotesDbAdapter.KeyScriptureTitle)), Scripture = cursor.GetString(cursor.GetColumnIndex(NotesDbAdapter.KeyScriptureContent)), ScriptureForHighlight = cursor.GetString(cursor.GetColumnIndex(NotesDbAdapter.KeyScriptureForHighlight)), NoteTitle = cursor.GetString(cursor.GetColumnIndex(NotesDbAdapter.KeyTitle)), NoteBody = cursor.GetString(cursor.GetColumnIndex(NotesDbAdapter.KeyBody)) }; notesList.Add(n); } }
//Gets the cursor view to show records according to search criteria void GetValidUserCursorView(string sUserName, string sPwd) { try { Android.Database.ICursor sqldb_cursor = myDb.getDatabaseUser_RecordCursor(sUserName, sPwd); if (sqldb_cursor != null) { isLogin=true; //Login successful sqldb_cursor.MoveToFirst (); //Identity column should be named "_id" in Android SQLite string[] from = new string[] {"_id","NAME","FLATNO","AGE" }; int[] to = new int[] { Resource.Id.Id_row, Resource.Id.Name_row, Resource.Id.Flat_row, Resource.Id.Age_row }; shMsg.Text = myDb.sqldb_message; // Welcome Message to the User is Observed here. SimpleCursorAdapter sqldb_adapter = new SimpleCursorAdapter (this, Resource.Layout.record_view, sqldb_cursor, from, to); listItems.Adapter = sqldb_adapter; hideControls(false); } else { //Login failed isLogin=false; listItems.Adapter=null; shMsg.Text = myDb.sqldb_message; hideControls(true); } } catch (Exception ex) { isLogin=false; listItems.Adapter=null; hideControls(true); var toast = Toast.MakeText (this, ex.Message ,ToastLength.Short); toast.Show (); } }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); SetContentView(Resource.Layout.HomeScreen); listView = FindViewById <ListView>(Resource.Id.List); //string[] projection = new string[] { VegetableProvider.InterfaceConsts.Id, VegetableProvider.InterfaceConsts.Name }; //string[] fromColumns = new string[] { VegetableProvider.InterfaceConsts.Name }; //int[] toControlIds = new int[] { Android.Resource.Id.Text1 }; //// ManagedQuery is deprecated in Honeycomb (3.0, API11) //cursor = ManagedQuery(VegetableProvider.CONTENT_URI, projection, null, null, null); //// ContentResolver requires you to close the query yourself ////cursor = ContentResolver.Query(VegetableProvider.CONTENT_URI, projection, null, null, null); ////StartManagingCursor(cursor); //// CursorLoader introduced in Honeycomb (3.0, API11) //var loader = new CursorLoader(this, // VegetableProvider.CONTENT_URI, projection, null, null, null); //cursor = (ICursor)loader.LoadInBackground(); string[] projection = new string[] { VegetableProvider.InterfaceConsts.Id, VegetableProvider.InterfaceConsts.Token }; string[] fromColumns = new string[] { VegetableProvider.InterfaceConsts.Token }; int[] toControlIds = new int[] { Android.Resource.Id.Text1 }; // CursorLoader introduced in Honeycomb (3.0, API_11) var loader = new CursorLoader(this, VegetableProvider.CONTENT_URI, projection, null, null, null); var cursor = (ICursor)loader.LoadInBackground(); if (cursor != null) { while (cursor.MoveToNext()) { string s = cursor.GetString(cursor.GetColumnIndexOrThrow("token")); Android.Util.Log.Debug("Test", "aaa " + s); } cursor.Close(); } Android.Util.Log.Debug("Test", "Create new item"); ContentValues content = new ContentValues(); content.Put(VegetableProvider.InterfaceConsts.Id, "3"); content.Put(VegetableProvider.InterfaceConsts.Token, "token3"); var ddd = ApplicationContext.ContentResolver.Insert(VegetableProvider.CONTENT_URI, content); Android.Util.Log.Debug("Test", "ddd: " + ddd); ICursor c = ApplicationContext.ContentResolver.Query(VegetableProvider.CONTENT_URI, null, null, null, null); if (c != null) { while (c.MoveToNext()) { string s = c.GetString(c.GetColumnIndexOrThrow("token")); Android.Util.Log.Debug("Test", "ccc " + s); } c.Close(); } // create a SimpleCursorAdapter cursor = ContentResolver.Query(VegetableProvider.CONTENT_URI, projection, null, null, null); adapter = new SimpleCursorAdapter(this, Android.Resource.Layout.SimpleListItem1, cursor, fromColumns, toControlIds); listView.Adapter = adapter; listView.ItemClick += OnListItemClick; }
void ShowResults (string query) { var cursor = ManagedQuery (DictionaryProvider.CONTENT_URI, null, null, new string[] {query}, null); if (cursor == null) { // There are no results textView.Text = GetString (Resource.String.no_results, query); } else { int count = cursor.Count; var countString = Resources.GetQuantityString (Resource.Plurals.search_results, count, count, query); textView.Text = countString; string[] from = new string[] { DictionaryDatabase.KEY_WORD, DictionaryDatabase.KEY_DEFINITION }; int[] to = new int[] { Resource.Id.word, Resource.Id.definition }; var words = new SimpleCursorAdapter (this, Resource.Layout.result, cursor, from, to); listView.SetAdapter (words); listView.ItemClick += (sender, e) => { var wordIntent = new Intent (ApplicationContext, typeof(WordActivity)); var data = Android.Net.Uri.WithAppendedPath (DictionaryProvider.CONTENT_URI, Java.Lang.String.ValueOf (e.Id)); wordIntent.SetData (data); StartActivity (wordIntent); }; } }
private void StartBillingStuff() { _handler = new Handler(); _inAppBillingDemoObserver = new InAppBillingDemoPurchaseObserver(this, _handler); _billingService = new BillingService(); _billingService.Context = this; ResponseHandler.Register(_inAppBillingDemoObserver); var inAppsSupported = _billingService.CheckBillingSupportedMethod(Consts.ITEM_TYPE_INAPP); var subscriptionsSupported = _billingService.CheckBillingSupportedMethod(Consts.ITEM_TYPE_SUBSCRIPTION); _purchaseDatabase = new PurchaseDatabase(this); OwnedItemsCursor = _purchaseDatabase.QueryAllPurchasedItems(); StartManagingCursor(OwnedItemsCursor); var from = new string[] { PurchaseDatabase.PURCHASED_PRODUCT_ID_COL, PurchaseDatabase.PURCHASED_QUANTITY_COL }; var to = new int[] { Resource.Id.itemName }; _ownedItemsAdapter = new SimpleCursorAdapter(this, Resource.Layout.Main, OwnedItemsCursor, from, to); if (OwnedItems.Count == 0) ItemName.Text = "No purchases"; }
private void FillData() { // Get all of the rows from the database and create the item list ICursor filesCursor = _dbHelper.FetchAllFiles(); StartManagingCursor(filesCursor); // Create an array to specify the fields we want to display in the list // (only TITLE) String[] from = new[] { FileDbHelper.KeyFileFilename }; // and an array of the fields we want to bind those fields to (in this // case just text1) int[] to = new[] { Resource.Id.file_filename }; // Now create a simple cursor adapter and set it to display SimpleCursorAdapter notes = new SimpleCursorAdapter(this, Resource.Layout.file_row, filesCursor, from, to); notes.ViewBinder = new MyViewBinder(App.Kp2a); ListAdapter = notes; }
public void FillData() { ICursor notesCursor = this.dbHelper.FetchAllNotes(); this.StartManagingCursor(notesCursor); // Create an array to specify the fields we want to display in the list (only TITLE) var from = new[] { NotesDbAdapter.KeyTitle, NotesDbAdapter.KeyBody, NotesDbAdapter.KeyScriptureTitle }; // and an array of the fields we want to bind those fields to (in this case just text1) var to = new[] { Resource.Id.textNoteTitle, Resource.Id.textNoteContent, Resource.Id.textNoteScriptureTitle }; // Now create a simple cursor adapter and set it to display notesAdapter = new SimpleCursorAdapter(this, Resource.Layout.NoteRow, notesCursor, from, to); notesAdapter.FilterQueryProvider = new FilterQueryProvider(c => notesCursor, dbHelper); this.ListAdapter = notesAdapter; notesList = new List<NoteScripture>(); while (notesCursor.MoveToNext()) { // Get all selected verses string[] verses = notesCursor.GetString(notesCursor.GetColumnIndex(NotesDbAdapter.KeyScriptureForHighlight)).Split(','); string verseList = ""; int pos = 2; while (pos < verses.Length) { string v = verses[pos].ToString(); verseList += v; if (pos < (verses.Length - 1)) { verseList += ","; } pos++; } NoteScripture n = new NoteScripture() { Id = int.Parse(notesCursor.GetString(notesCursor.GetColumnIndex(NotesDbAdapter.KeyRowId))), Title = notesCursor.GetString(notesCursor.GetColumnIndex(NotesDbAdapter.KeyScriptureTitle)), Scripture = notesCursor.GetString(notesCursor.GetColumnIndex(NotesDbAdapter.KeyScriptureContent)), ScriptureForHighlight = notesCursor.GetString(notesCursor.GetColumnIndex(NotesDbAdapter.KeyScriptureForHighlight)), NoteTitle = notesCursor.GetString(notesCursor.GetColumnIndex(NotesDbAdapter.KeyTitle)), NoteBody = notesCursor.GetString(notesCursor.GetColumnIndex(NotesDbAdapter.KeyBody)), NWTId = notesCursor.GetString(notesCursor.GetColumnIndex(NotesDbAdapter.KeyNWTId)), Book = verses[0], Chapter = verses[1], Verses = verseList }; notesList.Add(n); } }
/// <inheritdoc/> public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { ZTnTrace.Trace(MethodBase.GetCurrentMethod()); var view = inflater.Inflate(Resource.Layout.Home, container, false); var careerListView = view.FindViewById<ListView>(Resource.Id.AccountsListView); careerListView.ItemClick += (sender, args) => { var viewCareerIntent = new Intent(Activity, typeof(ViewCareerActivity)); D3Context.Instance.BattleTag = args.View.FindViewById<TextView>(Android.Resource.Id.Text1) .Text; D3Context.Instance.Host = args.View.FindViewById<TextView>(Android.Resource.Id.Text2) .Text; StartActivity(viewCareerIntent); }; D3Context.Instance.DbAccounts = new AccountsDB(Activity); cursor = D3Context.Instance.DbAccounts.GetAccounts(); Activity.StartManagingCursor(cursor); IListAdapter accountsAdapter = new SimpleCursorAdapter(Activity, Android.Resource.Layout.SimpleListItem2, cursor, accountsFromColumns, accountsToId); view.FindViewById<ListView>(Resource.Id.AccountsListView) .Adapter = accountsAdapter; return view; }
void BuscarPaisesCoincidan (string query) { var cursor = ManagedQuery (cpProveedorDatos.CONTENT_URI, null, null, new string[] {query}, null); if (cursor == null) { // No se encontraro resultados tv_Mensaje.Text = GetString (Resource.String.no_results, query); } else { int count = cursor.Count; var countString = Resources.GetQuantityString (Resource.Plurals.search_results, count, count, query); tv_Mensaje.Text = countString; string[] from = new string[] { Manejador_db.KEY_PAIS,Manejador_db.KEY_CONTINENTE }; int[] to = new int[] { Resource.Id.tv_Pais, Resource.Id.tv_Continente}; var words = new SimpleCursorAdapter (this, Resource.Layout.item_pais, cursor, from, to); lv_Paises.Adapter = words; } }