void Initialize()
        {
            _autoCompleteWords = new List <string>
            {
                "apple",
                "pineapple",
                "mikan",
                "ringo",
                "pear",
                "strawberry",
                "blueberry",
                "bananas"
            };

            var view = LayoutInflater.FromContext(Context).Inflate(Resource.Layout.auto_complete_edit_text, this);

            _inputField              = view.FindViewById <EditText>(Resource.Id.inputField);
            _inputField.TextChanged += (object sender, Android.Text.TextChangedEventArgs e) =>
            {
                SearchWord(e.Text.ToString());
                _autoCompleteArea.Visibility = ViewStates.Visible;
            };

            _autoCompleteArea = view.FindViewById <ListView>(Resource.Id.autocomplete_area);
            _adapter          = new ArrayAdapter(Context, Resource.Layout.listview_item, new List <string>());
            _adapter.SetNotifyOnChange(true);
            _autoCompleteArea.Adapter    = _adapter;
            _autoCompleteArea.ItemClick += (sender, e) =>
            {
                _inputField.Text = _autoCompleteArea.GetItemAtPosition(e.Position).ToString();
                _adapter.Clear();
                _autoCompleteArea.Visibility = ViewStates.Gone;
            };
        }
Exemplo n.º 2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="SpinnerObservableAdapter{T}"/> class.
        /// </summary>
        /// <param name="context">The current context.</param>
        /// <param name="resource">The resource ID for a layout file containing a <see cref="TextView"/> to use when instantiating views.</param>
        /// <param name="textViewResourceId">The id of the <see cref="TextView"/> within the layout resource to be populated.</param>
        /// <exception cref="ArgumentNullException"><paramref name="context"/> is <c>null</c>.</exception>
        public SpinnerObservableAdapter(Context context, int resource, int textViewResourceId)
        {
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }

            _adapter = new ArrayAdapter <T>(context, resource, textViewResourceId);
            _adapter.SetNotifyOnChange(false);
        }
Exemplo n.º 3
0
 private void SetupListView()
 {
     listAdapter = new ArrayAdapter <string>(this, Android.Resource.Layout.SimpleListItem1, ((String[])dataSource.ToArray(typeof(string))));
     //listAdapter = new ArrayAdapter<string>(this, Android.Resource.Layout.SimpleListItem1, observableDataSource);
     listAdapter.SetNotifyOnChange(true);
     listView.Adapter    = listAdapter;
     listView.ItemClick += (object sender, AdapterView.ItemClickEventArgs e) => {
         String selectedFromList = (string)listView.GetItemAtPosition(e.Position);
         Toast.MakeText(this, selectedFromList, ToastLength.Short).Show();
     };
 }
Exemplo n.º 4
0
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            if (container == null)
            {
                // Currently in a layout without a container, so no reason to create our view.
                return(null);
            }

            View view = inflater.Inflate(Resource.Layout.StatisticTabByDate, container, false);

            viewByDate = view;

            tbStatisticDateFrom = view.FindViewById <EditText>(Resource.Id.tbStatisticDateFrom);
            tbStatisticDateTo   = view.FindViewById <EditText>(Resource.Id.tbStatisticDateTo);
            tbStatisticCustName = view.FindViewById <AutoCompleteTextView>(Resource.Id.tbStatisticCustName);
            btnStatisticSearch  = view.FindViewById <Button>(Resource.Id.btnStatisticSearch);

            if (btnStatisticSearch != null)
            {
                btnStatisticSearch.Click += btnStatisticSearch_Click;
            }

            if (tbStatisticDateFrom != null)
            {
                tbStatisticDateFrom.Focusable = false;
                tbStatisticDateFrom.Click    += (object s, EventArgs e) => {
                    ShowCalendar(view.Context, tbStatisticDateFrom);
                };
            }

            if (tbStatisticDateTo != null)
            {
                tbStatisticDateTo.Focusable = false;
                tbStatisticDateTo.Click    += (object s, EventArgs e) => {
                    ShowCalendar(view.Context, tbStatisticDateTo);
                };
            }

            if (tbStatisticCustName != null && ObjectId > 0)
            {//  Android.Resource.Layout.SimpleDropDownItem1Line
                ArrayAdapter <String> adapter = new ArrayAdapter <String>(view.Context, Resource.Layout.suggestions_row, customerNames);
                adapter.SetNotifyOnChange(true);
                tbStatisticCustName.Adapter = adapter;
                adapter.NotifyDataSetChanged();
                tbStatisticCustName.Text = CustomerInfo.GetCustomer(view.Context, ObjectId).Name;
                btnStatisticSearch_Click(btnStatisticSearch, new EventArgs());
            }

            return(view);
        }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            // Set the result to CANCELED.  This will cause the widget host to cancel
            // out of the widget placement if they press the back button.
            SetResult(Result.Canceled, new Intent().PutExtra(AppWidgetManager.ExtraAppwidgetId, mAppWidgetId));

            // Find the widget id from the intent.
            if (Intent != null && Intent.Extras != null)
            {
                mAppWidgetId = Intent.GetIntExtra(AppWidgetManager.ExtraAppwidgetId, AppWidgetManager.InvalidAppwidgetId);
            }

            if (mAppWidgetId == AppWidgetManager.InvalidAppwidgetId)
            {
                // If they gave us an intent without the widget id, just bail.
                Finish();
            }

            SetContentView(Resource.Layout.activity_widget_setup);

            wm = WeatherManager.GetInstance();

            // Setup location spinner
            locSpinner = FindViewById <Spinner>(Resource.Id.location_pref_spinner);
            locSummary = FindViewById <TextView>(Resource.Id.location_pref_summary);

            var comboList = new List <ComboBoxItem>()
            {
                new ComboBoxItem(GetString(Resource.String.pref_item_gpslocation), "GPS"),
                new ComboBoxItem(GetString(Resource.String.label_btn_add_location), "Search")
            };
            var favs = Task.Run(Settings.GetFavorites).Result;

            Favorites = new ReadOnlyCollection <LocationData>(favs);
            foreach (LocationData location in Favorites)
            {
                comboList.Insert(comboList.Count - 1, new ComboBoxItem(location.name, location.query));
            }

            locAdapter = new ArrayAdapter <ComboBoxItem>(
                this, Android.Resource.Layout.SimpleSpinnerItem,
                comboList);
            locAdapter.SetDropDownViewResource(Android.Resource.Layout.SimpleSpinnerDropDownItem);
            locAdapter.SetNotifyOnChange(true);
            locSpinner.Adapter = locAdapter;

            FindViewById(Resource.Id.location_pref).Click += (object sender, EventArgs e) =>
            {
                locSpinner.PerformClick();
            };
            locSpinner.ItemSelected += (object sender, AdapterView.ItemSelectedEventArgs e) =>
            {
                CtsCancel();

                if (locSpinner.SelectedItem is ComboBoxItem item)
                {
                    locSummary.Text = item.Display;

                    if (item.Value.Equals("Search"))
                    {
                        mActionMode = StartSupportActionMode(mActionModeCallback);
                    }
                    else
                    {
                        selectedItem = item;
                    }
                }
                else
                {
                    selectedItem = null;
                }
                query_vm = null;
            };
            locSpinner.SetSelection(0);

            // Setup interval spinner
            refreshSpinner     = FindViewById <Spinner>(Resource.Id.interval_pref_spinner);
            var refreshSummary = FindViewById <TextView>(Resource.Id.interval_pref_summary);
            var refreshList    = new List <ComboBoxItem>();
            var refreshEntries = this.Resources.GetStringArray(Resource.Array.refreshinterval_entries);
            var refreshValues  = this.Resources.GetStringArray(Resource.Array.refreshinterval_values);

            for (int i = 0; i < refreshEntries.Length; i++)
            {
                refreshList.Add(new ComboBoxItem(refreshEntries[i], refreshValues[i]));
            }
            var refreshAdapter = new ArrayAdapter <ComboBoxItem>(
                this, Android.Resource.Layout.SimpleSpinnerItem,
                refreshList);

            refreshAdapter.SetDropDownViewResource(Android.Resource.Layout.SimpleSpinnerDropDownItem);
            refreshSpinner.Adapter = refreshAdapter;
            FindViewById(Resource.Id.interval_pref).Click += (object sender, EventArgs e) =>
            {
                refreshSpinner.PerformClick();
            };
            refreshSpinner.ItemSelected += (object sender, AdapterView.ItemSelectedEventArgs e) =>
            {
                if (refreshSpinner.SelectedItem is ComboBoxItem item)
                {
                    refreshSummary.Text = item.Display;
                }
            };
            refreshSpinner.SetSelection(
                refreshList.FindIndex(item => item.Value.Equals(Settings.RefreshInterval.ToString())));

            SetSupportActionBar(FindViewById <Android.Support.V7.Widget.Toolbar>(Resource.Id.toolbar));
            SupportActionBar.SetDisplayHomeAsUpEnabled(true);
            SupportActionBar.SetHomeAsUpIndicator(Resource.Drawable.ic_arrow_back_white_24dp);

            mActionModeCallback.CreateActionMode  += OnCreateActionMode;
            mActionModeCallback.DestroyActionMode += OnDestroyActionMode;

            FindViewById(Resource.Id.search_fragment_container).Click += delegate
            {
                ExitSearchUi();
            };

            appBarLayout      = FindViewById <AppBarLayout>(Resource.Id.app_bar);
            collapsingToolbar = FindViewById <CollapsingToolbarLayout>(Resource.Id.collapsing_toolbar);

            cts = new CancellationTokenSource();

            // Location Listener
            mLocListnr = new LocationListener();
            mLocListnr.LocationChanged += async(Android.Locations.Location location) =>
            {
                mLocation = location;
                await FetchGeoLocation();
            };

            if (!Settings.WeatherLoaded)
            {
                Toast.MakeText(this, GetString(Resource.String.prompt_setup_app_first), ToastLength.Short).Show();

                Intent intent = new Intent(this, typeof(SetupActivity))
                                .SetAction(AppWidgetManager.ActionAppwidgetConfigure)
                                .PutExtra(AppWidgetManager.ExtraAppwidgetId, mAppWidgetId);
                StartActivityForResult(intent, SETUP_REQUEST_CODE);
            }
        }
Exemplo n.º 6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SpinnerObservableAdapter{T}"/> class. Used when creating managed representations of JNI objects; called by the runtime.
 /// </summary>
 /// <param name="handle">A <see cref="IntPtr"/> containing a Java Native Interface (JNI) object reference.</param>
 /// <param name="transfer">A <see cref="JniHandleOwnership"/> indicating how to handle <paramref name="handle"/>.</param>
 public SpinnerObservableAdapter(IntPtr handle, JniHandleOwnership transfer)
     : base(handle, transfer)
 {
     _adapter = new ArrayAdapter <T>(handle, transfer);
     _adapter.SetNotifyOnChange(false);
 }