How to enable blinking cursor in Android SearchView

I have two SearchViews in my toolbar, and I would like to turn on the blinking cursor so that I can see which search I'm currently typing. When I start typing in SearchView, the cursor is not available. When I type a few more and then touch the text I typed, a blue pointing figure indicates the location of the clicked text - but the cursor does not appear.

How to turn on the program cursor of a black flashing rectangular line?

Some things I tried:

Maybe something is wrong with the setup of my search? Here is my setupSearchView code:

SearchManager searchManager = (SearchManager)getActivity().getSystemService(Context.SEARCH_SERVICE);
searchView.setSearchableInfo(searchManager.getSearchableInfo(getActivity().getComponentName()));
searchView.setIconified(false);
searchView.setonActionExpanded();
searchView.setQueryHint(hint);
searchView.setFocusable(true);
+4
2
   SearchView.SearchAutoComplete searchTextView =  mSearchView.findViewById(R.id.search_src_text);
        try {
            Field mCursorDrawableRes = TextView.class.getDeclaredField("mCursorDrawableRes");
            mCursorDrawableRes.setAccessible(true);
            mCursorDrawableRes.set(searchTextView, 0);
            //This sets the cursor resource ID to 0 or @null which will make it visible on white background
        } catch (Exception e) {
            e.printStackTrace();
        }
0

, , (TYPE_TEXT_VARIATION_NORMAL) SearchView. InputType TYPE_TEXT_VARIATION_FILTER , . , , , . Xamarin Android, Java .

SearchView.InputType = (int)InputTypes.TextVariationFilter;
0

Source: https://habr.com/ru/post/1624372/


All Articles