Ntikki
Ntikki

Reputation: 303

actionNext(or any ImeOption) doesn't work on my Edittext, also I can't select any other text field when this particular one is selected

This is such a confusing behavior to me, and I can't find anyone else with exactly my problem.

I am trying to create a login activity, and so far the username-field is giving me a lot of trouble. The textfield stays focused no matter what.

It doesn't lose focus if I click outside, I can't click any other field and I can't close the keyboard. Only back-button works in getting out. I tried making it a one-line field by using every combination of SingleLine, MaxLines and Lines.... I also tried to use ImeOptions/ImeActionId actionNext which also had no effect.

It stubbornly keeps its enter-button that continues to create new lines despite setting SingleLine to true.

Right now my xml looks like this:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    tools:context=".LoginActivity"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:gravity="center_horizontal"
    android:paddingTop="@dimen/spacing_huge">

    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/mini_logo"/>
    <RelativeLayout
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:padding="@dimen/spacing_huge">
        <ImageView
            android:layout_width="fill_parent"
            android:src="@drawable/orange_ring"
            android:layout_height="fill_parent"/>

        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:orientation="vertical"
            android:layout_centerInParent="true">


            <EditText
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:id="@+id/loginUsername"
                android:hint="Username"
                android:imeOptions="actionNext"
                android:singleLine="true"/>

            <EditText
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:id="@+id/loginPassword"
                android:hint="Password"
                android:inputType="textPassword"
                android:textAlignment="center"
                android:maxLines="1"
                android:singleLine="true"
                android:imeActionId="6"/>

            <Button
                android:id="@+id/loginButton"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:text="login!"
                android:onClick="userLogin"/>

        </LinearLayout>

    </RelativeLayout>

</LinearLayout>

Edit: ehm sorry, I forgot to ask the question. Can someone tell me what's going on or if I misunderstood something or how to fix this? :) I really have no idea what I can do right now. Thanks for your help.

Upvotes: 2

Views: 771

Answers (2)

AJay
AJay

Reputation: 1193

Combining android:maxLines="1" with android:inputType="text" works for you.

Upvotes: 2

QuokMoon
QuokMoon

Reputation: 4425

Add this line android:singleLine="true" to your EditText.

Upvotes: 0

Related Questions