java - Autocompletetextview show keyboard doesn't work -
I'm sure that tried to Android application, with Autocompletetextview include pieces, I want to show keyboard When the piece is displayed. I have tried, some things, but have not been successful.
Here is my code
xml
& lt; AutoCompleteTextView android: id = "@ + id / editArea" Android: layout_width = "match_parent" Android: layout_height = "wrap_content" Android: completionThreshold = "1" Android: singleLine = "true" Android: textcolor = "@ android: color / Primary_text_light "Android: gravity =" true "& gt; & Lt; / AutoCompleteTextView & gt;
My java piece
@Override public view onCreateView (LayoutInflater inflater, ViewGroup container, bundle savedInstanceState) {mLayout = inflater.inflate (R.layout. Change_area, blank, incorrect); Area = (autocomplete readview) mLayout.findViewById (R.id.editArea); ShowHideKeyboard (right); Citieslist = singletonicitylit.Testinstance (). GetList (); MAdapter = New Cities Adapter (getActivity), R.Lay Out. AutoComplete_text, Cities list); Area.setAdapter (mAdapter); Area.setThreshold (1); Area.setOnItemClickListener (this); Return mailout; } Private void showHideKeyboard (Boolean showhide) {if (showhide) {InputMethodManager inputMethodManager = (InputMethodManager) getActivity () .getSystemService (Context.INPUT_METHOD_SERVICE); Area.requestLayout (); If (inputMethodManager = null!) {InputMethodManager.toggleSoftInputFromWindow (getActivity () .getCurrentFocus () getApplicationWindowToken (), InputMethodManager.SHOW_FORCED, 0.); }} And {InputMethodManager imm = (InputMethodManager) getActivity () .getSystemService (Context.INPUT_METHOD_SERVICE); Imm.hideSoftInputFromWindow (area.getWindowToken (), 0); }}
Thanks for reading and helping me with this, have a nice day!
After you need to make a request to pay attention like this
AutoCompleteTextView yourView = findViewById (R.id.your_id); YourView.requestFocus ();
Comments
Post a Comment