android - Not setOnKeyListener nor setOnEditorActionListener working unexpectedly -
i trying thing when user press enter button in edittext (it multi lines edittext means user can write more 1 lines)
want detect either enter key pressed
code used given below
<edittext android:id="@+id/body" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@android:color/transparent" android:hint="@string/hint" android:padding="5dp" android:scrollbars="vertical" android:textcolor="@android:color/black" android:textcursordrawable="@null" android:textsize="22sp" />
and listener
mbodytext.setonkeylistener(new view.onkeylistener() { @override public boolean onkey(view view, int i, keyevent keyevent) { if ((keyevent.getaction()== keyevent.action_up)) { if(i == keyevent.keycode_enter){ toast.maketext(getapplicationcontext(), "neter presed", toast.length_long).show(); return true; } } return false; } });
but not show thing when press show when long press enter key
and setoneditoractionlistener
mbodytext.setoneditoractionlistener(new textview.oneditoractionlistener() { @override public boolean oneditoraction(textview textview, int i, keyevent keyevent) { if ((keyevent.getaction()== keyevent.action_up)) { if(i == keyevent.keycode_enter){ toast.maketext(getapplicationcontext(), "neter presed", toast.length_long).show(); return true; } } return false; } });
it shows nothing when press enter key , application crashes when long press enter key
please me trying long time
disappointed no 1 there answer question solved on own resources setonkeylistener not working because of android devices not support of them support
, setoneditoractionlistener caused crashes because trying data database , show in edittext view on activity starts
isma3l
Comments
Post a Comment