I want the functionallity
- just Enter -- EditText return and submit the text
- shift+Enter -- new line in EditText
this is the code but it don,t work. No difference between Enter and shift+Enter (no new line):
EditText text=(EditText)findViewById(R.id.text); text.setOnEditorActionListener( new OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if ( (actionId == EditorInfo.IME_ACTION_DONE) || ( (event.isShiftPressed()==false) && (event.getKeyCode() == KeyEvent.KEYCODE_ENTER) && (event.getAction() == KeyEvent.ACTION_DOWN ) ) ){ Editable buff=(Editable)v.getText(); writeText( buff.toString() ); context.finish(); // texten sparad här o activity avslutas return true; } return false; } });
in layout.xml:
android:inputType="text|textMultiLine"
android:imeOptions="actionDone"