Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using Android.App;
- using Android.Widget;
- using Android.OS;
- using System.Collections.Generic;
- using System;
- namespace ExamenPractico
- {
- [Activity(Label = "ExamenPractico", MainLauncher = true)]
- public class MainActivity : Activity
- {
- private TextView menu;
- private Spinner producto;
- private List<KeyValuePair<string, string>> menus;
- private EventHandler<AdapterView.ItemSelectedEventArgs> producto_ItemSelected;
- protected override void OnCreate(Bundle savedInstanceState)
- {
- base.OnCreate(savedInstanceState);
- // Set our view from the "main" layout resource
- SetContentView(Resource.Layout.Main);
- menu = (TextView)FindViewById(Resource.Id.menu);
- producto = (Spinner)FindViewById(Resource.Id.spinner1);
- producto.ItemSelected += new EventHandler<AdapterView.ItemSelectedEventArgs>(Producto_ItemSelected);
- menus = new List<KeyValuePair<string, string>>
- {
- new KeyValuePair<string, string>("Desayuno", "80"),
- new KeyValuePair<string, string>("Comida", "70"),
- new KeyValuePair<string, string>("Cena", "80"),
- };
- List<string> Productos = new List<string>();
- foreach (var item in menus)
- {
- Productos.Add(item.Key);
- }
- var adapter = new ArrayAdapter<string>(this, Android.Resource.Layout.SimpleSpinnerItem, Productos);
- producto.Adapter = adapter;
- }
- private void Producto_ItemSelected(object sender, AdapterView.ItemSelectedEventArgs e)
- {
- Spinner spinner = (Spinner)sender;
- {
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement