Reputation: 979
I am stuck into a problem that when iam using inputtype as textmultiline in xml and imeiOptions as KEYCODE_ENTER in edittext.Then my setOnEditorActionListener is not working but if i change my inputtype to text then its working fine.Iam not able to understand that why this is not working with textMultiline. My Edittext defined in xml is-:
<EditText
android:id="@+id/etremarks"
android:layout_width="match_parent"
android:layout_height="@dimen/_200sdp"
android:background="@drawable/shape_edittext_pink_border"
android:fontFamily="@font/share"
android:gravity="top"
android:hint="Enter Message"
android:inputType="textMultiLine"
android:padding="5dp"
android:textColor="#000000" />
and my code for edittext in java file is-:
etremarks.addTextChangedListener(mTextEditorWatcher);
etremarks.setImeOptions(KeyEvent.KEYCODE_ENTER);
etremarks.setOnEditorActionListener(new TextView.OnEditorActionListener()
{
@Override
public boolean onEditorAction(TextView v, int actionId,
KeyEvent event)
{
boolean handled = false;
if (actionId == KeyEvent.KEYCODE_ENTER)
{
// Handle pressing "Enter" key here
Toast.makeText(SendBulkSmsToClients.this, etremarks.getText(), Toast.LENGTH_SHORT).show();
handled = true;
}
return handled;
}
});
Please share your valuable opinions for this problem
thanks
Upvotes: 2
Views: 383
Reputation: 4208
Use
editText.setImeOptions(EditorInfo.IME_ACTION_DONE);
editText.setRawInputType(InputType.TYPE_CLASS_TEXT);
and in XML:
android:inputType="textMultiLine"
Source : Multi-line EditText with Done action button
Upvotes: 2
Reputation: 46
add this line android:imeOptions="actionSend"
and in the code , handle like this below
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
boolean handled = false;
if (actionId == EditorInfo.IME_ACTION_SEND) {
sendMessage();
handled = true;
}
return handled;
}
Upvotes: 0