android – dialog.getWindow()在创建对话框后返回null

android – dialog.getWindow()在创建对话框后返回null,第1张

概述@Overrideprotected Dialog onCreateDialog(int id) { Dialog dialog = null; switch(id) { case DIALOG_ID: LayoutInflater inflater = getLayoutInflater(); View InfoLayout = infl
@OverrIDeprotected Dialog onCreateDialog(int ID) {    Dialog dialog = null;    switch(ID) {    case DIALOG_ID:        LayoutInflater inflater = getLayoutInflater();        VIEw Infolayout = inflater.inflate(R.layout.info_dialog,null);        AlertDialog.Builder b = new AlertDialog.Builder(MyActivity.this)                .setVIEw(Infolayout );        initInfoDialog(dialog);        return dialog;...private voID initInfoDialog(Dialog dialog) {    //this line has the null pointer     WindowManager.LayoutParams lp = dialog.getwindow().getAttributes();

为什么dialog.getwindow()在这种情况下返回null?

解决方法 我遇到了同样的问题,我现在看到 getWindow()文档实际上是在说明原因(不是原因,而是为什么在这个特定点).您可以在致电 show()后检索窗口. 总结

以上是内存溢出为你收集整理的android – dialog.getWindow()在创建对话框后返回null全部内容,希望文章能够帮你解决android – dialog.getWindow()在创建对话框后返回null所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/1126936.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-30
下一篇 2022-05-30

发表评论

登录后才能评论

评论列表(0条)

保存