// Constructor public MainPage() { InitializeComponent(); // Sample code to localize the ApplicationBar //BuildLocalizedApplicationBar(); var restProcessor = new RestProcessor(); restProcessor.GetCountry(); }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); // Set our view from the "main" layout resource SetContentView(Resource.Layout.Main); // Get our button from the layout resource, // and attach an event to it Button button = FindViewById<Button>(Resource.Id.MyButton); Button button2 = FindViewById<Button>(Resource.Id.LoadDB); cName = FindViewById<TextView>(Resource.Id.countryName); nation = FindViewById<TextView>(Resource.Id.nationality); capital = FindViewById<TextView>(Resource.Id.capital); population = FindViewById<TextView>(Resource.Id.population); currency = FindViewById<TextView>(Resource.Id.currency); region = FindViewById<TextView>(Resource.Id.region); subregion = FindViewById<TextView>(Resource.Id.subregion); button.Click += delegate { var restProcessor = new RestProcessor(); restProcessor.GetCountry(); }; button2.Click += delegate { var repo = new DataRepository(); var country = repo.GetCountry("London"); if (country != null) { cName.Text = "Country Name -> " + country.Name; nation.Text = nation.Text + country.Nationality; capital.Text = capital.Text + country.Capital; population.Text = population.Text + country.Population; currency.Text = currency.Text + country.Currency; region.Text = region.Text + country.Region; subregion.Text = subregion.Text + country.Subregion; } else { cName.Text = "Country not found."; } }; }
// Sample code for building a localized ApplicationBar //private void BuildLocalizedApplicationBar() //{ // // Set the page's ApplicationBar to a new instance of ApplicationBar. // ApplicationBar = new ApplicationBar(); // // Create a new button and set the text value to the localized string from AppResources. // ApplicationBarIconButton appBarButton = new ApplicationBarIconButton(new Uri("/Assets/AppBar/appbar.add.rest.png", UriKind.Relative)); // appBarButton.Text = AppResources.AppBarButtonText; // ApplicationBar.Buttons.Add(appBarButton); // // Create a new menu item with the localized string from AppResources. // ApplicationBarMenuItem appBarMenuItem = new ApplicationBarMenuItem(AppResources.AppBarMenuItemText); // ApplicationBar.MenuItems.Add(appBarMenuItem); //} private void RetrieveData_OnClick(object sender, RoutedEventArgs e) { var restProcessor = new RestProcessor(); restProcessor.GetCountry(); }