Android的imeOptions变化纲领性 [英] Android imeOptions Change Programmatic

查看:159
本文介绍了Android的imeOptions变化纲领性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个EditText上txtPassword,txtEmail基于单选按钮更改事件我只是隐藏和显示txtPassword场
我只是想改变ImeOptions与porgrammatic为我写了下面的code

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

txtPassword.setImeOptions(EditorInfo.IME_ACTION_DONE);
txtEmail.setImeOptions(EditorInfo.IME_ACTION_NEXT); 


但是这是行不通的。当我看到软键盘这说明我做txtEmail行动(只是因为之前无线电只改变txtEmail可见,所以自动进行显示)
但手动focous在密码字段,比后之后,如果我看到的软键盘与电子邮件领域它自动旁边imeOptions改变了它。我只是想,如果一个txtEmail是可见的比它做了imeOptions如果txtPassword,txtEmail两者都比txtEmail可见旁边有ImeOptions和txtPassword它有显示器实现imeOptions。先谢谢了。

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.

编辑:


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));
}
}
});

推荐答案

试试这个,

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);
            }
        }
    });

和设置 passwordEditText.setImeOptions(EditorInfo.IME_ACTION_DONE); 总是

这篇关于Android的imeOptions变化纲领性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆