Change EditText IME_ACTION programmatically
<p>In my app I need to display one or two edittexts to collect information (e1 and e2), depending on the selection the user will do through a radiobutton. This is done by setting the visibility state  of the edittext to GONE and works fine.</p>

<p>My problem is how to programmatically set the IME_ACTION from "done" to "next" for each case, i.e.:</p>

<p>1) Only e1 is visible - set IME_ACTION of e1 to DONE</p>

<p>2) e1 and e2 are visible - set IME_ACTION of e1 to NEXT and IME_ACTION of e2 to DONE.</p>

<p>I'm using android:minSdkVersion="4" and android:targetSdkVersion="16" and testing on a Android 2.2 device.</p>

<p>Here's my layout:</p>

<pre><code>&lt;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"&gt;
&lt;/EditText&gt;         
&lt;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"&gt;
&lt;/EditText&gt; 
</code></pre>

<p>Here's my code:</p>

<pre><code>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;

    }
   }
  });  
</code></pre>
