Cristiano Guerra
Cristiano Guerra

Reputation: 635

Android EditText doesn't show the Keyboard

I have a screen with three EditText's, and one of then, the first one, in the top of the screen doesn't call the keyboard when I click on it. I'm not using an AVD, I'm using my own device, and tested in others devices and same result.

I'll put the screen here and the xml codes... there is nothing diferent between the EditTexts, just position. To make an input in that EditText I need to select one of the EditText above, and then the keyboard shows up. At least it doesn't hide when I select the first EditText again. I've already try the setFocus(true) and it doesn't solve my problem. please, help me!

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:background="@drawable/background"
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=".SaldoCadastro" >

<TextView
    android:id="@+id/tvTituloReg"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:layout_alignParentTop="true"
    android:text="Saldo Banco"
    android:textAppearance="?android:attr/textAppearanceLarge" />

<TextView
    android:id="@+id/tvErroSenha1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:layout_below="@+id/tvTituloReg"
    android:layout_marginTop="17dp"
    android:text="Insert on the field below how much you have in your bank." />

<TextView
    android:id="@+id/textView2"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@+id/tvErroSenha1"
    android:layout_below="@+id/tvErroSenha1"
    android:layout_marginTop="41dp"
    android:text="Insert on the field below how much is your credit card limit." />

<EditText
    android:id="@+id/etSaldo"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:layout_below="@+id/tvErroSenha1"
    android:ems="10"
    android:inputType="numberDecimal" >

    <requestFocus />
</EditText>

<EditText
    android:id="@+id/etCartaoLimite"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@+id/textView2"
    android:layout_below="@+id/textView2"
    android:ems="10"
    android:inputType="numberDecimal" />

<TextView
    android:id="@+id/textView3"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@+id/etCartaoLimite"
    android:layout_below="@+id/etCartaoLimite"
    android:text="About your credt card how much you&apos;ve spent already." />

<EditText
    android:id="@+id/etCartao"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@+id/textView3"
    android:layout_below="@+id/textView3"
    android:ems="10"
    android:inputType="numberDecimal" />

<Button
    android:id="@+id/btRegisterSaldo"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@+id/etCartao"
    android:layout_below="@+id/etCartao"
    android:layout_marginLeft="14dp"
    android:text="Register" />

Upvotes: 9

Views: 16847

Answers (6)

user1571055
user1571055

Reputation: 369

Please add attribute android:windowSoftInputMode="adjustResize" in AndroidManifest.xml

<activity
    ......
    android:windowSoftInputMode="adjustResize">

    ...
</activity>

Upvotes: 8

Parth Sharma
Parth Sharma

Reputation: 347

Hey Please check your AndroidManifest.xml activity and make some changes there like this

android:windowSoftInputMode="stateAlwaysVisible"

in activity where of this layout example:

<activity
    android:name="com.example.a.MainActivity"
    android:windowSoftInputMode="stateAlwaysVisible" // This will make your keyboard work
    android:label="@string/app_name" >

Upvotes: -1

lgw150
lgw150

Reputation: 178

Does you mean that when you start your activity, the soft_keyboard show up?if this, what you do just add this code:

android:windowSoftInputMode="adjustResize"

to your AndroidManifest.xml, for example like this:

   <activity
        android:name="com.fortrun.testcrashlytics.MainActivity"
        android:label="@string/app_name"
        android:windowSoftInputMode="adjustResize" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

hope to help you!

Upvotes: -1

Aldan
Aldan

Reputation: 715

Check your layout.xml if your layout implement android:descendantFocusability="blocksDescendants" remove it

Upvotes: 2

mohammad jalili
mohammad jalili

Reputation: 309

in my case, using android EditText instead of my custom EditText solved the problem .

Upvotes: 0

Sushil
Sushil

Reputation: 8478

Remove this line from xml:

<requestFocus />

else in code you can add this:

editText.clearFocus();

Upvotes: 0

Related Questions