在我的应用程序中,我需要显示一个或两个编辑框来收集信息(e1和e2),这取决于用户通过单选按钮进行的选择。这是通过将编辑框的可见性状态设置为“GONE”来完成的,并且运行良好。
我的问题是如何以编程方式将IME_ACTION从“done”设置为“next”,即:
1)只有e1可见 - 将e1的IME_ACTION设置为DONE
2)e1和e2都可见 - 将e1的IME_ACTION设置为NEXT,将e2的IME_ACTION设置为DONE。
我正在使用android:minSdkVersion="4"和android:targetSdkVersion="16",并在Android 2.2设备上进行测试。
这是我的布局:
<EditText
android:id="@+id/e1"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:inputType="text"
android:maxLines="1"
android:singleLine="true"
android:imeOptions="actionDone"
android:hint="@string/sh15"
android:textColor="@android:color/black"
android:textSize="@dimen/s">
</EditText>
<EditText
android:id="@+id/e2"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:inputType="text"
android:maxLines="1"
android:singleLine="true"
android:imeOptions="actionDone"
android:hint="@string/sh16"
android:textColor="@android:color/black"
android:textSize="@dimen/s">
</EditText>
这是我的代码:
这是我的代码:
RadioGroup r= (RadioGroup) dialog.findViewById(R.id.rg);
r.setOnCheckedChangeListener(new OnCheckedChangeListener()
{
public void onCheckedChanged(RadioGroup group, int checkedId)
{
switch(checkedId)
{
case R.id.rb1: //show one edittext
e1.setVisibility(View.VISIBLE);
e2.setVisibility(View.GONE);
e1.setImeOptions(EditorInfo.IME_ACTION_DONE);
break;
case R.id.rb2: //show two edittext
e1.setVisibility(View.VISIBLE);
e2.setVisibility(View.VISIBLE);
e1.setImeOptions(EditorInfo.IME_ACTION_NEXT);
e2.setImeOptions(EditorInfo.IME_ACTION_DONE);
break;
}
}
});