public void OnScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) { System.Diagnostics.Debug.WriteLine(firstVisibleItem); if (firstVisibleItem + visibleItemCount == totalItemCount) // Clear items, add from current half way to chunk size after last item, scroll back to old last item { var firstItem = adapter.GetItem(chunksize); adapter.Clear(); for (int i = 0; i < chunksize * 2; i++) { adapter.Add(firstItem.AddDays(i)); } adapter.NotifyDataSetChanged(); view.SetSelection(chunksize - visibleItemCount - 1); } else if (firstVisibleItem == 0) // Clear items, add from chunk size before first item, scroll back to old first item { var lastItem = adapter.GetItem(chunksize); adapter.Clear(); for (int i = chunksize * 2 - 1; i >= 0; i--) { adapter.Add(lastItem.AddDays(-i)); } adapter.NotifyDataSetChanged(); view.SetSelection(chunksize - 1); } }
private void SNetClient_OnDisconnect(object o, SocketEventArgs e) { Application.SynchronizationContext.Post((c) => { _adapter.Add("Disconnected from server!"); _adapter.NotifyDataSetChanged(); }, this); }
public void Log(string text) { RunOnUiThread(() => { _listAdapter.Add(text); _listView.InvalidateViews(); _listAdapter.NotifyDataSetChanged(); }); }
private void AddStringToList(string text) { if (!string.IsNullOrWhiteSpace(text)) { listAdapter.Add(text); prefs.AddString(text); } listAdapter.NotifyDataSetChanged(); }
private void OnDeleteClick(object sender, EventArgs e) { var checkedItems = _lv.GetCheckedItemIds(); foreach (var item in checkedItems) { MainActivity.UserManager.Delete(new SqlId((int)item)); } _adapter.NotifyDataSetChanged(); }
/// <summary> /// Méthode héritée de IChildListener : Gére la mise à jour d'une ligne au sein la base de données /// </summary> /// <see cref="IChildEventListener"/> /// <param name="snapshot"></param> public void OnChildChanged(DataSnapshot snapshot, string previousChildName) { if (snapshot.Value.ToString().Equals(Convert.ToString(0))) { // On teste si la valeur de participation est égale à 0 participantArrayList.Remove(snapshot.Key); // On enlève en temps réel les données d'un participant qui ne souhaiterait plus participer ... participantArrayAdapter.NotifyDataSetChanged(); // ... et on notifie à l'adaptateur que la liste des participants a changé !! } else if (snapshot.Value.ToString().Equals(Convert.ToString(1))) { // Sinon, on teste si la valeur de participation est égale à 1 participantArrayList.Add(snapshot.Key); // On ajoute les données à la liste des participant ... participantArrayAdapter.NotifyDataSetChanged(); // ... et on notifie à l'adaptateur que la liste des participants a changé !! } }
protected override async void OnResume() { base.OnResume(); _adapter.Clear(); _adapter.NotifyDataSetChanged(); _seenDevices.Clear(); var bleReady = await CheckPermissionAndAskIfNeeded(); if (bleReady) { CrossBleAdapter.Current.Scan().Subscribe(FoundDevice); } }
void UpdatePackages() { if (packageAdapter == null) { return; } RunOnUiThread(delegate { packageArray.Clear(); packageArray.AddRange(Packages); packageAdapter.NotifyDataSetChanged(); }); }
private void TxtExpense_Click(object sender, EventArgs e) { txtIncome.SetTextColor(Android.Graphics.Color.ParseColor("#B2DFDB")); txtExpense.SetTextColor(Android.Graphics.Color.White); txtTransfer.SetTextColor(Android.Graphics.Color.ParseColor("#B2DFDB")); Type = "Expense"; spinnerTransactionAccountTransfer.Visibility = ViewStates.Gone; adapterCategory.Clear(); adapterCategory.AddAll(listOfExpenseCategories); adapterCategory.NotifyDataSetChanged(); spinnerTransactionCategory.Visibility = ViewStates.Visible; txtTransactionCategory.Text = "Category"; txtTransactionAccount.Text = "Account"; }
private void BtnSave_Click(object sender, EventArgs e) { string word = etWord.Text.Trim().ToUpper(); string message = ""; if (word.Length == 0) { message = "Please Fill All Boxes"; } else { Word obj = new Word(); obj.WordString = word; if (connection.SaveWord(obj)) { message = "Word is Saved"; words.Add(word); adapter.NotifyDataSetChanged(); } else { message = "This Word is Already in List"; } } Toast.MakeText(this, message, ToastLength.Long).Show(); }
private void FlushData() { try { if (mbtSocket != null) { mbtSocket.Close(); mbtSocket = null; } if (mBluetoothAdapter != null) { mBluetoothAdapter.CancelDiscovery(); } if (btDevices != null) { btDevices.Clear(); btDevices = null; } if (mArrayAdapter != null) { mArrayAdapter.Clear(); mArrayAdapter.NotifyDataSetChanged(); mArrayAdapter.NotifyDataSetInvalidated(); mArrayAdapter = null; } Finish(); } catch (Exception ex) { } }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.activity_score); listaScore = FindViewById <ListView>(Resource.Id.listView1); btnMainMenu = FindViewById <Button>(Resource.Id.button1); jugadores = new List <Jugador>(); if (Intent.HasExtra("Jugadores")) { jugadores = JsonConvert.DeserializeObject <List <Jugador> >(Intent.GetStringExtra("Jugadores")); } jugadores.Add(new Jugador("Matias", 6)); jugadores.Add(new Jugador("Lucas", 3)); jugadores.Add(new Jugador("Martin", 7)); jugadores.Add(new Jugador("Marcos", 10)); jugadores.Add(new Jugador("Gonzalo", 1)); jugadores.Add(new Jugador("Laura", 2)); jugadores.Add(new Jugador("Gabriela", 0)); jugadores.Add(new Jugador("Monica", 3)); var jug = jugadores.OrderBy(i => i.MaxScore); List <String> listaJugadoresScore = new List <string>(); foreach (var jugador in jug) { listaJugadoresScore.Add(jugador.Nombre + " " + jugador.MaxScore); } ArrayAdapter arrayAdapter = null; arrayAdapter = new ArrayAdapter <string>(this, Android.Resource.Layout.SimpleListItem1, listaJugadoresScore); listaScore.Adapter = arrayAdapter; arrayAdapter.NotifyDataSetChanged(); btnMainMenu.Click += btnClickMainMenu; }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); // Set our view from the "main" layout resource SetContentView(Resource.Layout.ResultDetailsScreen); resultList = FindViewById <ListView>(Resource.Id.searchResultView); result = new List <string>() { "no data yet ..." }; myListAdapter = new ArrayAdapter(this, Android.Resource.Layout.SimpleListItem1, result); resultList.Adapter = myListAdapter; resultList.ItemClick += (s, e) => { //if (e.Position <= result.Count) //{ // var t = result[e.Position]; // Android.Widget.Toast.MakeText(this, t, Android.Widget.ToastLength.Long).Show(); //} }; myListAdapter.Clear(); var receivedData = Intent.GetStringArrayListExtra("data"); result = new List <string>(receivedData); myListAdapter.AddAll(result); RunOnUiThread(() => myListAdapter.NotifyDataSetChanged()); }
public void OnLocationChanged(Location location) { var locationLastUpdated = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc).AddMilliseconds(location.Time).ToLocalTime(); if (_lastLocation != null && _lastLocation.HasAccuracy && _lastLocation.Accuracy <= location.Accuracy) { _locationsListViewAdapter.Insert($"{locationLastUpdated.ToString("hh:mm:ss")} - Less accurate: {location.Accuracy}m vs. {_lastLocation.Accuracy}m", 0); } else { _locationsListViewAdapter.Insert($"{locationLastUpdated.ToString("hh:mm:ss")} - More accurate: {location.Accuracy}m vs. {(_lastLocation?.Accuracy ?? -1)}m\r\nlat: {location.Latitude}, long: {location.Longitude}", 0); Log.Info("Lat/Long", location.Latitude.ToString() + "," + location.Longitude.ToString()); _lastLocation = location; } _locationsListViewAdapter.NotifyDataSetChanged(); //if (_lastLocation == null) //{ // _addressButton.Text = $"Can't determine the current location. Try again in a few minutes."; //} //else //{ // var lastUpdated = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc).AddMilliseconds(_lastLocation.Time); // _addressButton.Text = $"lat: {_lastLocation.Latitude}, long: {_lastLocation.Longitude} (Last Updated {lastUpdated.ToLocalTime().ToString()}, accuracy {_lastLocation.Accuracy}m)"; //} }
private void updateView() { if (adapter != null) { adapter.NotifyDataSetChanged(); } if (headerView != null && today != null && profile != null) { headerView.FindViewById <TextView> (Resource.Id.textView1).Text = profile.user.full_name; } if (totalTextView != null && today != null) { totalTextView.StartAnimation(fadeoutAnimation); totalTextView.Text = today.challenge_profile.total_score.ToString(); totalTextView.StartAnimation(fadeinAnimation); } if (profileImageView != null && profileImage != null) { profileImageView.StartAnimation(fadeoutAnimation); profileImageView.SetImageDrawable((BitmapDrawable)profileImage.ToNative()); profileImageView.StartAnimation(fadeinAnimation); } }
private void Search_Click(object sender, EventArgs e) { adapter.Clear(); lstsearch.Visibility = ViewStates.Visible; try { if (edtsearch.Text.Length > 0) { string response = new WebClient().DownloadString("http://www.planmytrip.net23.net/search.php?ds=" + edtsearch.Text.Trim()); try { WebClient client = new WebClient(); Stream stream = client.OpenRead("http://www.planmytrip.net23.net/DATA/search.pmt"); int counting = 0; String content = ""; if (stream != null) { StreamReader reader = new StreamReader(stream); while (!reader.EndOfStream) { content = reader.ReadLine(); adapter.Add(content); adapter.NotifyDataSetChanged(); counting++; } reader.Close(); } stream.Close(); if (counting == 0) { adapter.Add("Destination does not exist"); } else if (counting > 1) { adapter.Add("Please search exact destination"); } if (adapter.Count > 0) { lstsearch.Adapter = adapter; } if (counting == 1 && content != "") { var intent = new Intent(this, typeof(userdataActivity)); intent.PutExtra("text", content); StartActivity(intent); } } catch (Exception) { Android.Widget.Toast.MakeText(this, "Error: Cannot find destination file", ToastLength.Short).Show(); } } else { Android.Widget.Toast.MakeText(this, "Error: Please fill the field", ToastLength.Short).Show(); } } catch (Exception) { Android.Widget.Toast.MakeText(this, "Error: Server down", ToastLength.Short).Show(); } }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.ServerSettings); bSaveServer = FindViewById <Button>(Resource.Id.bSaveServer); etServerNameSettings = FindViewById <EditText>(Resource.Id.etServerNameSettings); etServerAddressSettings = FindViewById <EditText>(Resource.Id.etServerAddressSettings); spinServers = FindViewById <Spinner>(Resource.Id.spinServerListSettings); serverList = new ArrayAdapter(this, Android.Resource.Layout.SimpleSpinnerItem, Android.Resource.Id.Text1); serverList.SetDropDownViewResource(Android.Resource.Layout.SimpleSpinnerDropDownItem); spinServers.Adapter = serverList; if (Settings.GameServers.Count == 0) { RefreshEnabled(false); } else { foreach (GameServer gameServer in Settings.GameServers) { serverList.Add(gameServer.ToShortString()); serverList.NotifyDataSetChanged(); } } spinServers.ItemSelected += spinServers_ItemSelected; spinServers.NothingSelected += spinServers_NothingSelected; bSaveServer.Click += bSaveServer_Click; }
public static void UpdateListview() { TempUser.GetContactNames(ref ContactNames); MyAdapater.Clear(); MyAdapater.AddAll(ContactNames); MyAdapater.NotifyDataSetChanged(); }
protected override void OnElementChanged(ElementChangedEventArgs <AutofillTextView> e) { base.OnElementChanged(e); if (Control == null) { var control = new InstantAutoCompleteTextView(Forms.Context); control.InputType = Android.Text.InputTypes.ClassText | Android.Text.InputTypes.TextFlagNoSuggestions; control.Text = Element.Text; SetNativeControl(control); } if (e.OldElement != null) { } if (e.NewElement != null) { var adapter = new ArrayAdapter <string>(Forms.Context as Android.App.Activity, Resource.Layout.AutofillTextViewItem, e.NewElement.Items.ToArray <string>()); Control.Adapter = adapter; Control.Threshold = 0; Control.TextChanged += Control_TextChanged; adapter.NotifyDataSetChanged(); } }
public void OnConnected(Bundle connectionHint) { mPersonListView.Adapter = mListAdapter; PlusClass.PeopleApi.LoadConnected(mGoogleApiClient) .SetResultCallback <IPeopleLoadPeopleResult> (result => { switch (result.Status.StatusCode) { case CommonStatusCodes.Success: mListItems.Clear(); var personBuffer = result.PersonBuffer; try { int count = personBuffer.Count; for (int i = 0; i < count; i++) { var person = personBuffer.Get(i).JavaCast <IPerson> (); mListItems.Add(person.DisplayName); } } finally { personBuffer.Close(); } mListAdapter.NotifyDataSetChanged(); break; case CommonStatusCodes.SignInRequired: mGoogleApiClient.Disconnect(); mGoogleApiClient.Connect(); break; default: Console.WriteLine("Error when listing people: " + result.Status); break; } }); }
private void UpdateSearchResult(object sender, SearchView.QueryTextChangeEventArgs e) { ShowLoadingView("Searching..."); var searchTerm = e.NewText.Trim(); Task runSync = Task.Factory.StartNew(async(object inputObj) => { var sTerm = inputObj != null ? inputObj.ToString() : ""; if (sTerm.Length > 2) { listData = await PerformSearch(sTerm); listContents = new List <String>(); for (var i = 0; i < listData.Count; i++) { listContents.Add(listData[i].description); } RunOnUiThread(() => { adapter = new ArrayAdapter <String> (this, Android.Resource.Layout.item_location, listContents); listView.Adapter = adapter; adapter.NotifyDataSetChanged(); }); } HideLoadingView(); }, searchTerm).Unwrap( ); }
/// <summary> /// This is called for activities that set launchMode to "singleTop" in their package, /// or if a client used the <see cref="Android.Content.ActivityFlags.SingleTop"/> flag when calling /// <see cref="Android.Content.ContextWrapper.StartActivity(Android.Content.Intent)"/>. /// </summary> /// <param name="intent">The new intent that was started for the activity.</param> protected override void OnNewIntent(Intent intent) { bool isBarcodeShouldBeDeleted = intent.GetBooleanExtra("delete", false); // if barcode should be deleted if (isBarcodeShouldBeDeleted) { // if clicked item index is correct if (_barcodeGeneratorFragment.ClickedItemIndex != -1) { // get adapter ArrayAdapter <Utils.BarcodeInformation> adapter = _barcodeGeneratorFragment.ListAdapter as ArrayAdapter <Utils.BarcodeInformation>; // remove barcode adapter.Remove(adapter.GetItem(_barcodeGeneratorFragment.ClickedItemIndex)); adapter.NotifyDataSetChanged(); } } else { // get barcode writer settings string xmlSerialization = intent.GetStringExtra("barcode"); if (xmlSerialization != null) { WriterSettings barcodeWriterSettings = Utils.DeserializeBarcodeWriterSettings(xmlSerialization); // get barcode description string barcodeDescription = intent.GetStringExtra("barcodeDescription"); // get barcode subset string barcodeSubset = intent.GetStringExtra("barcodeSubset"); string barcodeValue = intent.GetStringExtra("barcodeValue"); ArrayAdapter <Utils.BarcodeInformation> adapter = _barcodeGeneratorFragment.ListAdapter as ArrayAdapter <Utils.BarcodeInformation>; // if barcode writer settings is not empty if (barcodeWriterSettings != null) { // if clicked item index is correct if (_barcodeGeneratorFragment.ClickedItemIndex != -1) { // update list item Utils.BarcodeInformation item = adapter.GetItem(_barcodeGeneratorFragment.ClickedItemIndex); item.BarcodeWriterSetting = barcodeWriterSettings; item.BarcodeValue = barcodeValue; item.BarcodeDescription = barcodeDescription; item.BarcodeSubsetName = barcodeSubset; } else { // add value to the list adapter.Add(new Utils.BarcodeInformation(barcodeWriterSettings, barcodeValue, barcodeDescription, barcodeSubset)); } adapter.NotifyDataSetChanged(); } } } SaveHistory(); base.OnNewIntent(intent); }
protected virtual void NotifyAdapterChanged() { if (dropItemAdapter != null) { dropItemAdapter.NotifyDataSetChanged(); } }
public void OnDeviceFound(BluetoothDevice bluetoothDevice, BluetoothClass bluetoothClass) { if (bluetoothDevice == null) { return; } bool found = false; // in case of rescan check the one found isn't already in our list foreach (BluetoothDevice device in mBluetoothDevices) { if (device.Address == bluetoothDevice.Address) { found = true; break; } } if (!found) { mBluetoothDevices.Add(bluetoothDevice); mBluetoothArrayAdapter.Add(String.Format("{0} # {1}", bluetoothDevice.Name, bluetoothDevice.Address)); mBluetoothArrayAdapter.NotifyDataSetChanged(); } }
private void ConfigureFilePicker() { filePicker = new FilePicker(this); filePicker.Finished += (object sender, FilePicker.FinishedEventArgs e) => { if (e.PathToFile == null) { Toast.MakeText(this, "Book adding canceled.", ToastLength.Short); } else if (e.PathToFile.StartsWith("content://")) { Toast.MakeText(this, "Couldn't get the file by this path!", ToastLength.Short).Show(); } else if (System.IO.Path.GetExtension(e.PathToFile) == ".epub") { try { library.AddBook(e.PathToFile); adapter.Clear(); adapter.AddAll(library.GetAllBookNames()); adapter.NotifyDataSetChanged(); Toast.MakeText(this, "Parsing the book...", ToastLength.Short).Show(); } catch (Exception) { Toast.MakeText(this, "Couldn't parse the file!", ToastLength.Short).Show(); } } else { Toast.MakeText(this, "Not an epub file!", ToastLength.Short).Show(); } }; }
private void BtnPopOk_Click(object sender, EventArgs e) { if (txtCampaignName.Text.Length == 0) { View view = (View)sender; Snackbar.Make(view, "Must Enter a name", Snackbar.LengthLong) .SetAction("Action", (Android.Views.View.IOnClickListener)null).Show(); } else { View view = (View)sender; if (cc.AddCampaign(txtCampaignName.Text)) { adapter.Add(txtCampaignName.Text.ToString()); adapter.NotifyDataSetChanged(); popupDialog.Dismiss(); popupDialog.Hide(); } else { Snackbar.Make(view, "Campaign Already Exists", Snackbar.LengthShort) .SetAction("Action", (Android.Views.View.IOnClickListener)null).Show(); } } }
private void UpdateScanListView() { var listAdapter = new ArrayAdapter <string>(this, Android.Resource.Layout.SimpleListItem1, _scannedItems.ToArray()); listAdapter.NotifyDataSetChanged(); _scanList.Adapter = listAdapter; }
public void OnPeopleLoaded(ConnectionResult status, PersonBuffer personBuffer, String nextPageToken) { if (status.GetErrorCode() == ConnectionResult.SUCCESS) { mListItems.Clear(); try { int count = personBuffer.GetCount(); for (int i = 0; i < count; i++) { mListItems.Add(personBuffer.Get(i).GetDisplayName()); } } finally { personBuffer.Close(); } mListAdapter.NotifyDataSetChanged(); } else { Log.E(TAG, "Error when listing people: " + status); } }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); // Set our view from the "main" layout resource SetContentView(Resource.Layout.Main); MyEditText = FindViewById <EditText>(Resource.Id.MyEditText); MyButton = FindViewById <Button>(Resource.Id.MyButton); MyListView = FindViewById <ListView>(Resource.Id.MyListView); items = new List <string>(); items.Add("吃早餐"); adapter = new ArrayAdapter <string> (this, Android.Resource.Layout.SimpleListItem1, items); MyListView.Adapter = adapter; MyButton.Click += delegate { adapter.Add(MyEditText.Text); adapter.NotifyDataSetChanged(); Toast.MakeText(this, $"{MyEditText.Text} 已添加", ToastLength.Short) .Show(); }; }
protected override void OnProgressUpdate(params string[] values) { List <String> items = new List <String>(values); arrayAdapter.AddAll(items); arrayAdapter.NotifyDataSetChanged(); }
public void appendSpinner (Spinner spinMasterPanel, List<string> spinnerParentItems, ArrayAdapter<string> spinnerArrayAdapter, List<string> First) //Appending more items in the spinner { spinnerArrayAdapter.Clear (); spinnerArrayAdapter.NotifyDataSetChanged (); spinnerArrayAdapter.AddAll (First); spinnerArrayAdapter.AddAll (spinnerParentItems); spinnerArrayAdapter.NotifyDataSetChanged (); }