Android imeOptions Change Programmatic

I have two EditText txtPassword, txtEmail based on a radio change event. I just hide and show the txtPassword field. I just want to change ImeOptions using the program for which I wrote the following code

 txtPassword.setImeOptions(EditorInfo.IME_ACTION_DONE); txtEmail.setImeOptions(EditorInfo.IME_ACTION_NEXT); 
but it does not work. When I watch the soft keyboard, it shows that I did an action in txtEmail (only because before the radio has changed, only txtEmail is visible, so it automatically appears) but after manual focus in the password field and after As I see a soft keyboard with an email field, it automatically changed it using the following imeOptions. I just want one txtEmail to be visible than imeOptions, and if txtPassword, txtEmail are both visible than txtEmail, ImeOptions next and in txtPassword it displays imeOptions. Thanks in advance.

Edit:

 radiologin.setOnCheckedChangeListener(new OnCheckedChangeListener() { public void onCheckedChanged(RadioGroup group,int checkedId) { // checkedId is the RadioButton selected if (checkedId == R.id.radioWithoutPassword) { txtPassword.setVisibility(View.GONE); txtEmail.setBackgroundDrawable(getResources().getDrawable(R.drawable.both_corner)); txtEmail.setImeOptions(EditorInfo.IME_ACTION_DONE); } else { txtEmail.setImeOptions(EditorInfo.IME_ACTION_NEXT); txtPassword.setImeOptions(EditorInfo.IME_ACTION_DONE); txtPassword.setVisibility(View.VISIBLE); txtEmail.setBackgroundDrawable(getResources().getDrawable(R.drawable.top_corner)); } } }); 

+2
source share
2 answers

Try it,

 final EditText passwordEditText = new EditText(this); final EditText emailEditText = new EditText(this); RadioButton button = new RadioButton(this); button.setOnCheckedChangeListener(new RadioButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { // TODO Auto-generated method stub if(isChecked){ passwordEditText.setVisibility(View.INVISIBLE); emailEditText.setImeOptions(EditorInfo.IME_ACTION_DONE); }else{ emailEditText.setImeOptions(EditorInfo.IME_ACTION_NEXT); } } }); 

and always set passwordEditText.setImeOptions(EditorInfo.IME_ACTION_DONE); .

+1
source

I had the same problem. what worked with me adds android:singleLine="true" and I mention any imeOptions or the following focus values. I got the expected result. on the first editText keyboard, the following will be displayed if another editText is still visible while it is still showing: -p

0
source

All Articles