I'm designing a custom keyboard for Android. I want to have my custom label for ENTER key for some fields in my application. I used sample SoftKeyboard project for developing my keyboard. What I tried so far: 1- In one of my activities I have an EditText with the following attributes:
<EditText
android:id="@+id/password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:imeActionId="@+id/action_sign_in"
android:imeActionLabel="@string/sign_in"
android:inputType="textPassword" />
If I use Native Android keyboard it shows "Sign In" on my enter key but if I use my custom keyboard it shows the default value of enter key in the following statement:
void setImeOptions(Resources res, int options)
{
if (mEnterKey == null)
{
return;
}
switch (options & (EditorInfo.IME_MASK_ACTION | EditorInfo.IME_FLAG_NO_ENTER_ACTION))
{
case EditorInfo.IME_ACTION_GO:
mEnterKey.iconPreview = null;
mEnterKey.icon = null;
mEnterKey.label = res.getText(R.string.label_send_key);
break;
case EditorInfo.IME_ACTION_NEXT:
mEnterKey.iconPreview = null;
mEnterKey.icon = null;
mEnterKey.label = res.getText(R.string.label_next_key);
break;
case EditorInfo.IME_ACTION_SEARCH:
mEnterKey.icon = res.getDrawable(R.drawable.sym_keyboard_search);
mEnterKey.label = null;
break;
case EditorInfo.IME_ACTION_SEND:
mEnterKey.iconPreview = null;
mEnterKey.icon = null;
mEnterKey.label = res.getText(R.string.label_send_key);
break;
case R.id.action_sign_in:
mEnterKey.iconPreview = null;
mEnterKey.icon = null;
mEnterKey.label = res.getText(R.string.sign_in);
break;
default:
mEnterKey.label = res.getText(R.string.label_send_key);
mEnterKey.icon = null;
break;
}
}
}
I would appreciate if someone can help me to solve this issue.