2013-08-21 2 views
3

У меня есть экран с тремя EditText, и один из них, первый, в верхней части экрана, не вызывает клавиатуру, когда я нажимаю на нее. Я не использую AVD, я использую свое устройство и тестирую на других устройствах и тот же результат.Android EditText не показывает клавиатуру

Я поставлю экран здесь и коды xml ... Между EditTexts и просто позицией нет ничего. Чтобы сделать ввод в этом EditText, мне нужно выбрать один из EditText выше, а затем появится клавиатура. По крайней мере, он не скрывается, когда я снова выбираю первый EditText. Я уже пробовал setFocus (true), и это не решает мою проблему. , пожалуйста, помогите мне!

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" /> 

+0

Я не мог показать изображение, потому что у меня недостаточно репутации, извините, ребята. –

ответ

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

пожалуйста, добавьте этот атрибут в AndroidManifest.xml

+0

ОК спасибо! Это помогло! –

+0

Правильно, дайте мне голос, спасибо. – user1571055

0

Удалить эту строку из XML:

<requestFocus /> 

еще в коде можно добавить следующее:

editText.clearFocus(); 
+0

Следует ли добавлять clearFocus() во все EditTexts или просто в том, что он «сломан»? –

+0

Осцилер не работает :). Вы можете добавить ко всем. Я думаю, что в вашем xml вы добавили к одному, который был сломан. – Sushil

+0

Да, я сделал ... попытался заставить его работать, прочитать некоторые учебники и другой ответ, и они сказали, что это решит мою проблему, но это не так. –

0

Эй Пожалуйста, проверьте AndroidMainfest активностьи внести некоторые изменения там, как этот

 android:windowSoftInputMode="stateAlwaysVisible" 

в деятельности, где в этом примере макета:

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

ли вы имеете в виду, что: Когда вы начинаете свою деятельность, появляется soft_keyboard? Если это так, вы просто добавляете этот код:

android:windowSoftInputMode="adjustResize" 

к вашему AndroidManifest.xml , например, как это:

<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> 

надежда, чтобы помочь вам!

Смежные вопросы