显示警报Activity.onCreate(..)

编程入门 行业动态 更新时间:2024-10-26 08:30:27
本文介绍了显示警报Activity.onCreate(..)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我是新来的Andr​​oid,这是我在这里的第一个问题,所以请去容易对我。

I am new to Android and this is my first question here so please go easy on me.

是否有可能来检查活动的一些内幕情况的onCreate(),并显示一个AlertDialog?

Is it possible to check some condition inside onCreate() of an Activity and display an AlertDialog?

我创建一个AlertDialog匿名在OnCreate中(),并在该实例上调用秀,但AlertDialog永远不会显示。

I am creating an AlertDialog anonymously in Oncreate() and calling show on that instance but the AlertDialog is never displayed.

推荐答案

显示中的onCreate警告对话框导致android.view.WindowLeaked例外,因为该活动尚未创建。

Showing an alert dialog in onCreate causes android.view.WindowLeaked exception, because the activity isn't yet created.

我找到解决的办法是把code,显示在ONSTART)对话框(方法:

The solution I found is to put the code that shows the dialog in onStart() method:

@Override protected void onStart() { super.onStart(); // show dialog here }

更多推荐

显示警报Activity.onCreate(..)

本文发布于:2023-11-27 16:55:24,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1638833.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:警报   Activity   onCreate

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!