Android – When the keyboard in the clip is open, the alarm dialog will not move upward.

I have dynamically created a warning dialog in the fragment. It has an edit text and a button. My problem is that when the user is focused on editing the text, the keyboard opens, it hides Dialog button. My dialog did not move to the top.

private void AlertEditMode(final MyIshVo myIshVo) {
final LinearLayout linearLayout=new LinearLayout( getContext());
final EditText edittext = new EditText(getContext());
LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,LinearLayout.LayoutParams.WRAP_CONTENT);
layoutParams.setMargins(50,0,50,0);
edittext.setLayoutParams(layoutParams);
linearLayout.addView(edittext);
final AlertDialog dialog = new AlertDialog.Builder( getContext())
.setView(linearLayout)
.setTitle("Instant Share")
.setPositiveButton(android.R.string.ok, null) //Set to null. We override the onclick
.setNegativeButton(android.R.string.cancel, null)
.create();


// relativeL ayout.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);

edittext.setText(myIshVo.getMish_name());

edittext.setSelection(edittext.getText( ).length());
dialog.setOnShowListener(new DialogInterface.OnShowListener() {

@Override
public void onShow(final DialogInterface dialog) {
< br /> Button button = ((AlertDialog) dialog).getButton(AlertDialog.BUTTON_POSITIVE);
button.setOnClickListener(new View.OnClickListener() {

@Override
public void onClick(View view) {
String ish_title = edittext.getText().toString().trim();
String instant_share_Id=myIshVo.getMinstant_share_Id();
if(ish_title== null || ish_title.equalsIgnoreCase("") || ish_title.contains("<") || ish_title.contains("\") ){
//showToastMessage("Title shoul d not be Empty");
edittext.setError("Please enter valid title.");
}else{
presenter.setEditIsh(ish_title,instant_share_Id);
dialog. dismiss();
}
}
});
}
});
dialog.show();
// dialog .getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);

}

I have tried to assign adjustresize to the activity and give it dynamically

getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);

Both solutions do not work. Other solutions please express thanks in advance.

[! [View image] [1]] [1]

When the Activity that displays the AlertDialog has a semi-transparent state I encountered this problem when using the bar theme.

So, instead of using the classic AlertDialog.Builder(context) that uses the context theme to initialize the builder, you explicitly pass the one without a translucent status bar Dialog theme:

AlertDialog.Builder(context, android.R.style.Theme_DeviceDefault_Light_Dialog_NoActionBar)

I chose this theme because it ensures that Compatibility of devices before Lollipop, but other devices like android.R.style.Theme_Material_Dialog can also do this.

I have dynamic in the fragment Created a warning dialog box. It has an edit text and a button. My problem is that when the user is focused on editing text the keyboard opens, its hidden dialog button. My dialog does not move to the top.

< /p>

private void AlertEditMode(final MyIshVo myIshVo) {
final LinearLayout linearLayout=new LinearLayout(getContext());
final EditText edittext = new EditText(getContext ());
LinearLayout.LayoutParams layoutParams =new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,LinearLayout.LayoutParams.WRAP_CONTENT);
layoutParams.setMargins(50,0,50,0);
edittext.setLayoutParams(layoutParams);
linearLayout.a ddView(edittext);
final AlertDialog dialog = new AlertDialog.Builder(getContext())
.setView(linearLayout)
.setTitle("Instant Share")
.setPositiveButton( android.R.string.ok, null) //Set to null. We override the onclick
.setNegativeButton(android.R.string.cancel, null)
.create();


// relativeLayout.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);

edittext.setText(myIshVo.getMish_name());

edittext.setSelection(edittext.getText().length());
dialog.setOnShowListener(new DialogInterface.OnShowListener() {

@Override
public void onShow( final DialogInterface dialog) {

Button button = ((AlertDialog) dialog).getButton(AlertDialog.BUTTON_POSITIVE);
button.setOnClickListener(new View.OnClickListener() {
< br /> @Override
public void onClick(View view) {
String ish_title = edittext.getText().toString().trim();
String instant_share_Id=myIshVo.getMinstant_share_Id();
if(ish_title= =null || ish_title.equalsIgnoreCase("") || ish_title.contains("<") || ish_title.contains("\") ){
//showToastMessage("Title should not be Empty") ;
edittext.setError("Please enter valid title.");
}else{
presenter.setEditIsh(ish_title,instant_share_Id);
dialog.dismiss();
}
}
});
}
});
dialog.show();
// dialog.getWindow().setSoftInputMode (WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);

}

I have tried to assign adjustresize to the activity and give it dynamically

getWindow ().setSoftInputMode(WindowManager.LayoutP arams.SOFT_INPUT_ADJUST_RESIZE);

Both solutions do not work. Other solutions please express thanks in advance.

[! [View image] [1]] [1]

I ran into this problem when the Activity displaying the AlertDialog had a semi-transparent status bar theme.

So, instead of using the classic AlertDialog.Builder(context) to initialize the builder using the context theme, you explicitly pass the dialog theme without a translucent status bar:

< /p>

AlertDialog.Builder(context, android.R.style.Theme_DeviceDefault_Light_Dialog_NoActionBar)

I chose this theme because it ensures compatibility with pre-Lollipop devices, but like android .R.style.Theme_Material_Dialog can also do this.

WordPress database error: [Table 'yf99682.wp_s6mz6tyggq_comments' doesn't exist]
SELECT SQL_CALC_FOUND_ROWS wp_s6mz6tyggq_comments.comment_ID FROM wp_s6mz6tyggq_comments WHERE ( comment_approved = '1' ) AND comment_post_ID = 3560 ORDER BY wp_s6mz6tyggq_comments.comment_date_gmt ASC, wp_s6mz6tyggq_comments.comment_ID ASC

Leave a Comment

Your email address will not be published.