Exemplo n.º 1
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            Xamarin.Essentials.Platform.Init(this, savedInstanceState);
            SetContentView(Resource.Layout.activity_main);
            Android.Support.V7.Widget.Toolbar toolbar = FindViewById <Android.Support.V7.Widget.Toolbar>(Resource.Id.toolbar);
            SetSupportActionBar(toolbar);

            FloatingActionButton fab = FindViewById <FloatingActionButton>(Resource.Id.fab);

            fab.Click += FabOnClick;

            cc = new CampaignController();
            cc.CreateDatabase();

            camps = GetExistingCampaigns();
            if (camps[0] == null)
            {
                camps = new List <string>();
            }
            adapter  = new ArrayAdapter <string>(this, Android.Resource.Layout.SimpleListItem1, camps);
            listView = new ListView(this);
            var padding = Convert.ToInt32(TypedValue.ApplyDimension(ComplexUnitType.Dip, 4, this.Resources.DisplayMetrics));

            listView.SetPadding(padding, padding, padding, padding);

            listView.Adapter = adapter;

            listView.TextFilterEnabled = true;

            listView.ItemClick += delegate(object sender, AdapterView.ItemClickEventArgs args) {
                ISharedPreferences sharedprefs = GetSharedPreferences("prefs_file", FileCreationMode.Private);
                sharedprefs.Edit().PutString("Campaign", ((TextView)args.View).Text).Commit();
                var intent = new Intent(this, typeof(NotesActivity));
                StartActivity(intent);
            };
            LinearLayout ll = FindViewById <LinearLayout>(Resource.Id.main_content_layout);

            ll.AddView(listView);
        }