2016-04-26 12 views
0

フォームアクティビティでは、3つのフィールドがあります。サーバーにフォームを確認した後、それは終了し、前のアクティビティに進みます。しかし、問題は、キーボードがまだポップアップし、前の活動は入力フィールドを持っていない終了した後。 ここにレイアウトファイルがあります。EditTextフォーカスはアクティビティの終了後に行われません

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="vertical" 
    android:background="@color/colorWhite" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 

    <include layout="@layout/toolbar"/> 

    <ScrollView 
     android:layout_width="match_parent" 
     android:layout_height="match_parent"> 

     <LinearLayout 
      android:layout_gravity="center" 
      android:layout_margin="20dp" 
      android:orientation="vertical" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent"> 

      <sslwireless.com.easycorporate.Fonts.LoraBold 
       android:layout_marginBottom="20dp" 
       android:text="@string/change_password_title" 
       android:textSize="25sp" 
       android:textColor="@color/colorAccent" 
       android:gravity="center" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" /> 


      <EditText 
       android:id="@+id/oldPassword" 
       android:background="@drawable/super_white_style" 
       android:padding="12dp" 
       android:layout_marginTop="15dp" 
       android:singleLine="true" 
       android:inputType="textPassword" 
       android:hint="@string/hints_old_password" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" /> 

      <EditText 
       android:id="@+id/newPassword" 
       android:background="@drawable/super_white_style" 
       android:padding="12dp" 
       android:layout_marginTop="15dp" 
       android:singleLine="true" 
       android:inputType="textPassword" 
       android:hint="@string/hints_new_password" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" /> 


      <EditText 
       android:id="@+id/confirmPassword" 
       android:background="@drawable/super_white_style" 
       android:padding="12dp" 
       android:layout_marginTop="15dp" 
       android:singleLine="true" 
       android:inputType="textPassword" 
       android:hint="@string/hints_confirm_password" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" /> 

      <Button 
       android:id="@+id/changePassword" 
       android:text="@string/change_password" 
       android:layout_marginTop="20dp" 
       android:textColor="@color/colorWhite" 
       android:background="@drawable/primary_dark_color_style" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" /> 

     </LinearLayout> 

    </ScrollView> 

</LinearLayout> 

ここで実際に何が起こっていますか。

enter image description here

私はまた、マニフェストファイルの両方の活動のためにandroid:windowSoftInputMode="stateHidden"を設定します。以前の活動に戻った後でフォーカスを削除する方法はありますか?近くkeybordのためのコードの下

+0

はそう、あなたがしたいですある時点でソフトキーボードを隠す。右 ?自動的には起こりません。 –

+0

そうですね。 –

+0

なぜ私は投票を停止していますか? –

答えて

1

あなたは(あなたの前finish()アクティビティ)閉じるようにIMEを強制することがあります。

public void hideSoftKeyboard(@NonNull Activity activity) { 
    IBinder windowToken = activity.getWindow().getDecorView().getRootView().getWindowToken(); 
    InputMethodManager imm = (InputMethodManager)activity.getSystemService(Context.INPUT_METHOD_SERVICE); 
    imm.hideSoftInputFromWindow(windowToken, 0); 
} 
+0

それは動作します。助けてくれてありがとう。 –

0

コールは、仕上げActivityonStop()でボタン

InputMethodManager imk = (InputMethodManager) activity.getSystemService(Activity.INPUT_METHOD_SERVICE); 
     if (imk.isActive()){ 
      imk.toggleSoftInput(InputMethodManager.HIDE_IMPLICIT_ONLY, 0); // hide key board 
     } 
+0

私は前のアクティビティには 'edittext'がないとすでに言いました。 –

1

をクリックすると、呼び出しソフトキーボードが消えるようにするために、このようなすべてのEditTextのフィールドを無効にします。

EditText et = (EditText)findViewById(R.id.confirmPassword); 
et.setEnabled(false); 
0

今日、実際には同じバグが修正されました。

@Override 
public void closeKeyboard(View view) { 
    InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); 
      //Log.d("RKZ", "isKeyboardShown("+((ViewGroup) findViewById(android.R.id.content)).getChildAt(0)+") = "+isKeyboardShown(((ViewGroup) findViewById(android.R.id.content)).getChildAt(0))); 
    if(view != null && Util.isSoftKeyboardShown(imm, view)) { 
     Util.hideKeyboard(ActivityASG.this, view); 
    } 
} 

そして、あなたのCHANGE PINボタンのonClick()はちょうどこのようにそれを呼び出すことで

  //close keyboard 
      callback.closeKeyboard(noteInput); 
      callback.closeKeyboard(mailInput); 
      //callback.closeKeyboard(yourCHANGE_PINview); 
関連する問題