KeyCode_Enter to next edittext

You have to use the requestFocus method. In your case it will be something like:

tCNPCode.setOnKeyListener(new OnKeyListener() {
    public boolean onKey(View v, int keyCode, KeyEvent event) {
        if(keyCode == KeyEvent.KEYCODE_ENTER) {
            txtCNPCode.requestFocus();
        }
        return false;
    }
});

You don't even have to use OnKeyListener. Simply add line android:singleLine="true" to your EditText. After this operation EditText behaves exactly like you want. So, in your particular case:

<EditText
    android:id="@+id/txtNPCode"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:textSize="18sp"
    android:layout_alignLeft="@+id/lblNPCode"
    android:layout_below="@+id/lblNPCode"
    android:layout_centerHorizontal="true"
    android:singleLine="true"
/>
<EditText
    android:id="@+id/txtCNPCode"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:textSize="18sp"
    android:layout_alignLeft="@+id/lblCNPCode"
    android:layout_below="@+id/lblCNPCode"
    android:layout_centerHorizontal="true"
/>

solves the problem.


The best way is to use one of the options for inputType, for example: android:inputType="textPersonName" This will achieve the wanted effect. Check out the other options too, it'll save you some time in future :)

You shouldn't use android:singleLine="true", since it's deprecated. Here's what the documentations says about it:

This attribute is deprecated and is replaced by the textMultiLine flag in the inputType attribute. Use caution when altering existing layouts, as the default value of singeLine is false (multi-line mode), but if you specify any value for inputType, the default is single-line mode. (If both singleLine and inputType attributes are found, the inputType flags will override the value of singleLine.).