androidandroid-edittextandroid-softkeyboardimeoptions

how to avoid "actionDone" for EditText


I am trying to display softkeyboard for my EditText.Here I am having a problem regarding imeoptions.my requirement is : actionDone should never be visible to user when toggle softkeyboard.always actionNext should be visible. What i am facing is: when user toggle keyboard,for first time it shows actionNext but when user type data and then click on keyboard toggler it is showing actionDone option.but here i want actionNext only.Beside,if the user clears the field and again toggle keyboard it is showing actionDone only but not actionNext. conclusion:i want only the actionNext in any scenario. this is my code for toggling softkeyboard:

btn_keyboard.setOnClickListener(new View.OnClickListener() {
         @Override
         public void onClick(View v) {
         //actv_ServiceLoc.setInputType(InputType.TYPE_CLASS_TEXT);
         InputMethodManager inputMgr = (InputMethodManager)                      
           getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
         //inputMgr.toggleSoftInput(EditorInfo.IME_ACTION_NEXT,   
          EditorInfo.IME_ACTION_DONE);
      inputMgr.toggleSoftInput
       (EditorInfo.IME_FLAG_NO_ENTER_ACTION,EditorInfo.IME_ACTION_DONE);
       //actv_ServiceLoc.setText("");

        actv_ServiceLoc.requestFocus();
       if(actv_ServiceLoc.getText().toString().length()==0) {
        actv_ServiceLoc.setImeOptions(EditorInfo.IME_ACTION_NEXT);
         }
         else
              {
           actv_ServiceLoc.setImeOptions(EditorInfo.IME_ACTION_NEXT);

              }
         actv_ServiceLoc.setFocusableInTouchMode(true);
               location_error.setVisibility(myView.GONE);

                  }
               });

Thanks in advance.


Solution

  • writing below single line before toggling keyboard helps you show always 'actionNext' button in your keyboard.

    actv_ServiceLoc.setInputType(InputType.TYPE_TEXT_FLAG_AUTO_COMPLETE);
    //your ui control.setInputType(InputType.YourFlag);