daily pastebin goal
33%
SHARE
TWEET

Untitled

a guest Mar 22nd, 2018 63 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using Android.App;
  2. using Android.Widget;
  3. using Android.OS;
  4. using System.Collections.Generic;
  5. using System;
  6.  
  7. namespace ExamenPractico
  8. {
  9.     [Activity(Label = "ExamenPractico", MainLauncher = true)]
  10.     public class MainActivity : Activity
  11.     {
  12.         private TextView menu;
  13.         private Spinner producto;
  14.         private List<KeyValuePair<string, string>> menus;
  15.         private EventHandler<AdapterView.ItemSelectedEventArgs> producto_ItemSelected;
  16.  
  17.         protected override void OnCreate(Bundle savedInstanceState)
  18.         {
  19.             base.OnCreate(savedInstanceState);
  20.  
  21.             // Set our view from the "main" layout resource
  22.             SetContentView(Resource.Layout.Main);
  23.             menu = (TextView)FindViewById(Resource.Id.menu);
  24.             producto = (Spinner)FindViewById(Resource.Id.spinner1);
  25.  
  26.             producto.ItemSelected += new EventHandler<AdapterView.ItemSelectedEventArgs>(Producto_ItemSelected);
  27.  
  28.             menus = new List<KeyValuePair<string, string>>
  29.             {
  30.                 new KeyValuePair<string, string>("Desayuno", "80"),
  31.                 new KeyValuePair<string, string>("Comida", "70"),
  32.                 new KeyValuePair<string, string>("Cena", "80"),
  33.             };
  34.             List<string> Productos = new List<string>();
  35.             foreach (var item in menus)
  36.             {
  37.                 Productos.Add(item.Key);
  38.             }
  39.  
  40.             var adapter = new ArrayAdapter<string>(this, Android.Resource.Layout.SimpleSpinnerItem, Productos);
  41.  
  42.             producto.Adapter = adapter;
  43.         }
  44.         private void Producto_ItemSelected(object sender, AdapterView.ItemSelectedEventArgs e)
  45.         {
  46.             Spinner spinner = (Spinner)sender;
  47.             {
  48.  
  49.             }
  50.  
  51.         }
  52.     }
  53. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top