public override bool OnCreateOptionsMenu(IMenu menu)
        {
            MenuInflater.Inflate(Resource.Menu.menu_search_2, menu);

            SearchManager searchManager = ( SearchManager )GetSystemService(SearchService);
            SearchView    searchView    = ( SearchView )menu.FindItem(Resource.Id.menu_search).ActionView;

            searchView.SetSearchableInfo(searchManager.GetSearchableInfo(ComponentName));
            searchView.OnActionViewExpanded( );
            return(true);
        }
        private void ConnectSearchView()
        {
            var ctx = (Activity)context;

            if (CoreSettings.SearchView != 0)
            {
                _searchView = ctx?.FindViewById <SearchView>(CoreSettings.SearchView);
            }

            if (_searchView == null)
            {
                return;
            }

            var contentPage = Element as ContentPage;

            if (contentPage == null)
            {
                _searchView.Visibility = ViewStates.Gone;
                return;
            }

            _searchProvider = contentPage.BindingContext as ISearchProvider;

            if (_searchProvider == null)
            {
                _searchView.Visibility = ViewStates.Gone;
                return;
            }

            if (!string.IsNullOrEmpty(_searchProvider.QueryHint))
            {
                _searchView.SetQueryHint(_searchProvider.QueryHint);
            }

            _searchView.QueryTextSubmit += HandleQueryTextSubmit;

            if (_searchProvider.SearchIsDefaultAction)
            {
                _searchView.OnActionViewExpanded();
            }
            else
            {
                _searchView.OnActionViewCollapsed();
            }

            _searchView.Visibility = ViewStates.Visible;
        }
Exemplo n.º 3
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.ZoekLand);
            //GET LOGIN STATUS
            bool   LoginCheck = Intent.GetBooleanExtra("LoginCheck", false);
            int    mUserID    = Intent.GetIntExtra("mUserID", 0);
            string Username   = Intent.GetStringExtra("Username");


            _lv = FindViewById <ListView>(Resource.Id.lv);
            _sv = FindViewById <SearchView>(Resource.Id.sv);

            addData();

            _adapter = new ArrayAdapter(this, Android.Resource.Layout.SimpleListItem1, _al);

            _lv.Adapter = _adapter;

            _sv.QueryTextChange += _sv_QueryTextChange;
            _lv.ItemClick       += (sender, e) => _lv_ItemClick(sender, e, LoginCheck, mUserID, Username);

            btnZoekBack        = FindViewById <Button>(Resource.Id.btnZoekBack);
            btnZoekBack.Click += BtnZoekBack_Click;


            // SET TEXT COLOR & HINT TEXT COLOR

            SearchView sv = FindViewById <SearchView>(Resource.Id.sv);
            int        id = sv.Context.Resources.GetIdentifier("android:id/search_src_text", null, null);
            TextView   tv = (TextView)sv.FindViewById(id);

            tv.SetTextColor(Android.Graphics.Color.ParseColor("#e77d4d"));
            sv.SetQueryHint("Typ hier om een land te zoeken.");

            sv.OnActionViewExpanded();
        }
Exemplo n.º 4
0
        private void searchByText(object sender, EventArgs e)
        {
            //change focus off button
            Button mButton = (Button)sender;

            mButton.Focusable = false;

            //Get activity and the searchView. Set Listener on it
            MainActivity act     = (MainActivity)this.Activity;
            SearchView   searchV = (SearchView)act.FindViewById(Resource.Id.searchView1);

            //loses focus on search view if it already given focus before ((allows for backout without querying and pressing the button again))
            if (flagSearch)
            {
                searchV.Focusable = false;
                searchV.SetIconifiedByDefault(true);
                searchV.OnActionViewCollapsed();
            }

            searchV.RequestFocus();
            searchV.SetIconifiedByDefault(false);
            searchV.OnActionViewExpanded();
            flagSearch = true;
        }
Exemplo n.º 5
0
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            View view = inflater.Inflate(Resource.Layout.ax_Search, container, false);

            // _w.RecyclerView rez = view as _w.RecyclerView;

            __view    = view;
            ___view   = view;
            ax_search = this;

            var bar = __view.FindViewById <ProgressBar>(Resource.Id.progressBar1);

            //bar.Visibility = ViewStates.Gone;
            pbar = bar;

            // _w.RecyclerView rez = view as _w.RecyclerView; //inflater.Inflate(Resource.Layout.ax_Search, container, false) as _w.RecyclerView;
            SearchView search = view.FindViewById <SearchView>(Resource.Id.movie_seach);

            _w.RecyclerView re = view.FindViewById <_w.RecyclerView>(Resource.Id.recyclerView_movies);
            _re = re;

            search.SetQueryHint(new Java.Lang.String("Movie Search"));
            //search.SetQuery(new Java.Lang.String("HELLO"), true);

            search.QueryTextSubmit += async(o, e) =>
            {
                search.ClearFocus();

                if (searchDone)
                {
                    searchDone             = false;
                    MainActivity.searchFor = e.Query;
                    // Intent intent = new Intent(search.Context, typeof(SearchResultsActivity));
                    //StartActivity(intent);
                    Action onCompleted = () =>
                    {
                        //print("daaaaaaaaaaaaaaaa")
                        // UpdateList();
                        ChangeBar(100);
                        searchDone = true;
                        //
                    };

                    sThred = new Java.Lang.Thread(
                        () =>
                    {
                        try {
                            Search(e.Query);
                            //Thread.Sleep(1000);
                        }
                        finally {
                            onCompleted();
                            sThred.Join();
                            //invoke(onCompleted);
                        }
                    });
                    sThred.Start();

                    ChangeBar(0);
                }
            };
            re.SetItemClickListener((rv, position, _view) =>
            {
                SelectMovie(rv, position, _view);
            });

            re.LongClickable = true;

            /*
             * re.LongClickable = true;
             * re.SetOnLongClickListener((rv, position, _view) =>
             * {
             *  //An item has been clicked
             *  HistoryPressTitle(movieTitles[wlink[position]]);
             *  movieSelectedID = wlink[position];
             *  Context context = _view.Context;
             *  Intent intent = new Intent(context, typeof(SearchResultsActivity));
             *  // intent.PutExtra(CheeseDetailActivity.EXTRA_NAME, values[position]);
             *
             *  context.StartActivity(intent);
             *
             * });
             */
            /*
             * var buttons = view.FindViewById<LinearLayout>(Resource.Id.s_Buttons);
             *
             * LinearLayout linearLayout = buttons; //new LinearLayout(this);
             * linearLayout.Orientation = (Android.Widget.Orientation.Vertical);
             *
             * for (int i = 0; i < 100; i++) {
             *  var button = new Button(this.Context);
             *  button.Text = "Button " + i;
             *  button.LayoutParameters = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.WrapContent);
             *  button.Click += (o, e) =>
             *  {
             *      //selectedTitle = button.Text;
             *      //ClosePoster(ViewStates.Visible);
             *      Intent intent = new Intent(search.Context, typeof(SearchResultsActivity));
             *      StartActivity(intent);
             *  };
             *  linearLayout.AddView(button);
             *  btts.Add(button);
             * }*/


            // bar.Progress = MainActivity.bar_progress;

            //IRunnable
            // search.SetQuery("test", true);
            //  search.SetFocusable(ViewFocusability.Focusable);
            //search.SetIconifiedByDefault(false);
            search.OnActionViewExpanded();
            search.ClearFocus();
            searchView = view.FindViewById <SearchView>(Resource.Id.movie_seach);

            // imm.HideSoftInputFromInputMethod(search.WindowToken, HideSoftInputFlags.None);
            //search.RequestFocusFromTouch();


            return(view);
        }