Reputation: 2010
I have two EditText txtPassword,txtEmail based on radiobutton change event I just hide and show txtPassword field
I just want to change ImeOptions with porgrammatic for that I wrote following code
but this is not working. When I observe soft-keyboard this shows me done action in txtEmail (just because before radio changed only txtEmail is visible so automatic done appear)
but after manually focous in password field and than after if I observe soft-keyboard with email field it automatic changed it with next imeOptions. I just want if One txtEmail is visible than it have done imeOptions and if txtPassword,txtEmail both are visible than txtEmail have ImeOptions next and in txtPassword it have display done imeOptions. Thanks in advance.txtPassword.setImeOptions(EditorInfo.IME_ACTION_DONE);
txtEmail.setImeOptions(EditorInfo.IME_ACTION_NEXT);
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));
}
}
});
Upvotes: 4
Views: 4374
Reputation: 1254
i had the same issue. what worked with me is adding android:singleLine="true"
and i dint mention any imeOptions or next focus values. i got the expected result. in first editText keyboard shows next if another editText is visible else it shows done :-p
Upvotes: 0
Reputation: 3713
Try this,
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 set passwordEditText.setImeOptions(EditorInfo.IME_ACTION_DONE);
always.
Upvotes: 2