Quantcast
Channel: Recent Threads — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 204402

Hide keyboard when EditText lose the focus in a recyclerview

$
0
0

Hi, I have a recyclerview and an adapter for it with an EditText. I want hide the keyboard when hits EditText los the focus. I tried using InputMethoManager (imm = (InputMethodManager)GetSystemService(Context.InputMethodService) but I'm receiving an error in GetSystemService and in the InputMethodService that says that "GetSystemService doesn't exist in the current context".

public class MilestonesViewHolder : RecyclerView.ViewHolder
{

InputMethodManager imm;
public EditText Title { get; private set; }

public MilestonesViewHolder(View itemView) : base(itemView)
{
MainView = itemView;
Title = itemView.FindViewById(Resource.Id.tv_milestones_title);
imm = (InputMethodManager)GetActivity().GetSystemService(Context.InputMethodService);
Title.AfterTextChanged += Title_AfterTextChanged;
Title.FocusChange += Title_FocusChange;
}

private void Title_FocusChange(object sender, View.FocusChangeEventArgs e)
{
if (!e.HasFocus)
{
imm.HideSoftInputFromWindow(Title.WindowToken, 0);
}
}
}


Viewing all articles
Browse latest Browse all 204402

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>