I want the functionallity
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"
I think you need to use a shift key listener and keep a boolean to detect when your shift key is pressed, like so:
@Override
public boolean onKey(View v, int keyCode, KeyEvent event)
{
switch (v.getId())
{
case R.id.myEditTextId:
if(keyCode==59)//59 is shift's keycode
//do your stuff here against pressing shift key
break;
}
}