예제 #1
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            ViewGroup root = FindViewById <ViewGroup>(Android.Resource.Id.Content);

            SetContentView(Resource.Layout.SettingsLayout);

            SetSupportActionBar(FindViewById <Android.Support.V7.Widget.Toolbar>(Resource.Id.SettingsToolbar));

            SettingsListView = (ListView)FindViewById(Resource.Id.SettingsListView);

            SettingsListAdapter = new ViewGeneratorArrayAdapter(
                this,

                (pos, convertView, parent) =>
            {
                View view = convertView ?? LayoutInflater.Inflate(Android.Resource.Layout.SimpleListItem1, null);
                view.FindViewById <TextView>(Android.Resource.Id.Text1).Text = "TODO: Add proper settings.";
                return(view);
            },

                (pos, convertView, parent) =>
            {
                View view = convertView ?? LayoutInflater.Inflate(Android.Resource.Layout.SimpleListItem1, null);
                view.FindViewById <TextView>(Android.Resource.Id.Text1).SetText(Resource.String.License);
                ListActions[pos] = () =>
                {
                    AlertDialog dialog = null;
                    using (AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(this))
                    {
                        TextView msg = new TextView(this);
                        msg.SetText(Resource.String.Licenses);
                        msg.ApplyHTML();

                        msg.SetPadding(20, 20, 20, 20);

                        ScrollView msgScroll = new ScrollView(this);
                        msgScroll.AddView(msg);

                        dialogBuilder.SetTitle(Resource.String.License);
                        dialogBuilder.SetView(msgScroll);
                        dialogBuilder.SetCancelable(true);
                        dialogBuilder.SetPositiveButton(Android.Resource.String.Ok, (s, e) =>
                        {
                            dialog.Dismiss();
                        });
                        dialog = dialogBuilder.Show();
                    }
                };
                return(view);
            },

                (pos, convertView, parent) =>
            {
                View view   = convertView ?? LayoutInflater.Inflate(Android.Resource.Layout.SimpleListItem1, null);
                TextView tv = view.FindViewById <TextView>(Android.Resource.Id.Text1);
                tv.SetText(Resource.String.ListTail);
                tv.ApplyHTML();
                return(view);
            }
                );
            SettingsListView.Adapter = SettingsListAdapter;

            SettingsListView.ItemClick += (s, e) =>
            {
                Action action;
                if (ListActions.TryGetValue(e.Position, out action))
                {
                    action?.Invoke();
                }
            };
        }