Android - have IME enter key submit? -


is there way have enter key submit form? right have log in button sent using addlistenerbutton()... can somehow link enter key well? think code .java irrelevant, can post if requested.

xml:

<relativelayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingbottom="@dimen/activity_vertical_margin" android:paddingleft="@dimen/activity_horizontal_margin" android:paddingright="@dimen/activity_horizontal_margin" android:paddingtop="@dimen/activity_vertical_margin" tools:context=".mainactivity"  android:id="@+id/back" android:background="@drawable/a_hdpi">  <linearlayout      android:orientation="vertical"     android:layout_width="match_parent"     android:layout_height="wrap_content"     android:layout_centerinparent="true"     android:padding="10dp"     android:background="@drawable/linearlayout_bg" >  <edittext     android:id="@+id/username"     android:layout_width="match_parent"     android:layout_height="wrap_content"     android:background="@drawable/edittext_top_bg"     android:padding="10dp"     android:hint="username"     android:textcolorhint="#cccccc"     android:drawableleft="@drawable/user"  />  <edittext     android:id="@+id/password"     android:layout_width="match_parent"     android:layout_height="wrap_content"     android:background="@drawable/edittext_bottom_bg"     android:layout_margintop="-2dp"     android:padding="10dp"     android:hint="password"     android:singleline="true"     android:textcolorhint="#cccccc"     android:drawableleft="@drawable/password"      android:password="true"     android:imeoptions="actionsend" />  <button     android:id="@+id/submit"     android:layout_width="match_parent"     android:layout_height="wrap_content"     android:padding="10dp"     android:layout_margin="4dp"     android:text="submit"     style="@style/defaultbuttontext"     android:background="@drawable/button_default_bg" /> 

yes, find reference edittext have added android:imeoptions="actionsend" , set oneditoractionlistener trigger method or button onclick login want trigger.

edittext youredittext = findviewbyid(r.id.password); youredittext.setoneditoractionlistener(new oneditoractionlistener() {     public boolean oneditoraction(textview v, int actionid, keyevent event) {         if (actionid == editorinfo.ime_action_send) {             login(); // login method here             return true;         }         return false;     } }); 

Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -