解决 AlertDialog 中 EditText 自动弹出

解决 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);
}
发布了18 篇原创文章 · 获赞 11 · 访问量 1万+

猜你喜欢

转载自blog.csdn.net/INTKILOW/article/details/77935143