How can I open the keyboard when a fragment starts? I have already tried this code:
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
view =inflater.inflate(R.layout.mylayout,container,false);
TextView TVLarghezza = (TextView) view.findViewById(R.id.larghezza);
TVLarghezza.requestFocus();
InputMethodManager imgr = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
imgr.showSoftInput(view, InputMethodManager.SHOW_IMPLICIT);
return view;
}
But it doesn't work. I have to open the keyboard at startup.