有没有办法让Enter键提交我的表单?现在我有一个登录按钮,使用addListenerButton()
发送......我可以以某种方式将Enter键链接到该按钮吗?我认为我的.java代码是不相关的,但如果需要,我总是可以发布它。Android - 有IME输入密钥提交?
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" />