解决 AlertDialog 中 EditText 自动弹出
解决 AlertDialog 中 EditText 自动弹出 影响弹出动画
本人亲测通过!!!!!!
主要部分
Window win = dialog.getWindow();
win.setWindowAnimations(R.style.dialogWindowAnim);
win.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
dialog.show();
public class ChooseAlertDialog {
private Context context;
private CharSequence[] charSequences;
private CallBackDialogInterface callback;
private AlertDialog.Builder builder;
private String title;
public ChooseAlertDialog(Context context, CallBackDialogInterface callback, CharSequence[] charSequences,String title) {
this.context = context;
this.charSequences = charSequences;
this.callback = callback;
this.title = title;
builder = new AlertDialog.Builder(context);
}
public void show(){
AlertDialog dialog = builder.setTitle(title)
//.setIcon(R.drawable.ic_launcher)
.setItems(charSequences, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
Log.i("TAG", "选择:"+charSequences[which]);
callback.call(charSequences[which]+"");
}
}).create();
Window win = dialog.getWindow();
win.setWindowAnimations(R.style.dialogWindowAnim);
win.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
dialog.show();
}
}
public interface CallBackDialogInterface {
void call(String str);
}