2017-04-06 20 views
-1

私はEditText入力フィールドを含むレイアウトを持っています。このレイアウトの上にAlertDialog(Advertisement)がポップアップしています。問題は、EditTextをクリックしてもSoftKeyBoardがポップアップしないということです。この要件を達成するための回避策はありますか?AlertDialog EditTextレイアウトの上にキーボードが表示されない

enter image description here

レイアウト:

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:id="@+id/activity_secondary" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    tools:context="inova.lk.com.librarytestapp.main.SecondaryActivity"> 

    <EditText 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:padding="20dp" 
     android:layout_margin="20dp" 
     android:hint="Enter Name" 
     android:focusableInTouchMode="true" 
     android:layout_centerInParent="true"/> 
</RelativeLayout> 

AlertDialog:

final Dialog dialog = new Dialog(activity); 

dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); 
    dialog.setContentView(inova.lk.com.inapplibrary.R.layout.custom_dialog_layout); 
dialog.setCancelable(false); 

Window window = dialog.getWindow(); 
window.setFlags(
     WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL, 
     WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL 
); 

window.clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND); 
window.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT)); 

WindowManager.LayoutParams wmlp = dialog.getWindow().getAttributes(); 
wmlp.width = Utility.dpToPx(320); 
wmlp.height = Utility.dpToPx(50); 

dialog.show(); 

UPDATE *****

私はGoogleのADZのような広告SDKを開発しています。 AlertDialogは私のadzバナーです。 edittextレイアウトの上にあるバナーは1つのシナリオです。したがって、自分のSDKを使用するユーザーに変更を加える必要のないソリューションが必要です。

+0

あなたのxmlからこの行を削除してください "android:focusableInTouchMode =" true " " –

+1

可能な複製:http://stackoverflow.com/questions/3455235/when-using-alertdialog-builder-with-edittext-the-ソフトキーボードのdoesnt-pop – rafsanahmad007

+0

@ rafsanahmad007質問をお読みください。ここで私は別のシナリオについて話しています。あなたが指摘した質問は、EditTextがAlertDialogの内部に何が入っているかについて話していることです。 –

答えて

0

dialog.show()の前にこれらの行を挿入します。

try{ 
     dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE); 
    }catch (Exception e){ 
     e.printStackTrace(); 
     } 
+0

EditTextにAlertDialogが含まれている場合には、この問題が発生します。ありがとうございます –

+0

次にrequestFocus(edittext);を試してください –

+0

私はadzのような広告SDKを開発しています。あなたの側で変更を加える必要がないソリューションが必要です。 –

0

私はAlertDialog(広告)をポップアップしています。

なぜAlertDialogを使用する必要がありますか?広告は常にレイアウトの上に配置されるため、AlertDialogは必要ありません。代わりに、FrameLayoutを使用してレイアウトの上部に配置するだけです。

+0

私はSDKを開発しているし、adzの種類(グーグルadzのような)があります。たとえば、トップバナー、ボトムバナー、フルスクリーンバナーなど、カスタムビューを提供する場合、開発者はそのビューをレイアウトのどこにでも配置できます。私はトップバナー、ボトムバナーなどを開発者に強制することはできません –

関連する問題