gpt4 book ai didi

android - 调用 Toast 时发生未知膨胀错误

转载 作者:太空宇宙 更新时间:2023-11-03 11:18:46 26 4
gpt4 key购买 nike

我有一个已发布的应用程序,它收到了一些奇怪的用户反馈。根据堆栈跟踪,在尝试调用 Toast show() 方法时出现膨胀错误。堆栈如下:

android.view.InflateException: Binary XML file line #21: Error inflating class <unknown>
at android.view.LayoutInflater.createView(LayoutInflater.java:596)
at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
at android.view.LayoutInflater.onCreateView(LayoutInflater.java:644)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:669)
at android.view.LayoutInflater.inflate(LayoutInflater.java:457)
at android.view.LayoutInflater.inflate(LayoutInflater.java:391)
at android.view.LayoutInflater.inflate(LayoutInflater.java:347)
at android.widget.Toast.makeText(Toast.java:247)
at my.app.name.Launcher$ActionDecider.onPostExecute(Launcher.java:155)

在第 155 行,我只是对 Toast 的 show() 进行了一次普通调用:

Toast.makeText(LauncherAct.getContext(), "Some random string here", Toast.LENGTH_SHORT).show();

有人知道它可能是什么吗?

最佳答案

我遇到了同样的问题。突然,我的 Toast 调用开始出现此错误 Binary XML file line #21: Error inflating class。我在同一方法中再次调用我的方法,直到从网络提供商那里获得所需的 gps 值。当我删除记忆本身时,问题就消失了。我没有弄清楚它们之间的关系,但这很有效。

public void getLocation()
{
if(gps.canGetLocation())
{
latitude = gps.latitude;
longitude = gps.longitude;
if((latitude < 0) || (longitude < 0))
{
Toast.makeText(CharityGPS.this, "Konumunuz saptanıyor lütfen bekleyiniz.", Toast.LENGTH_SHORT).show();
getLocation(); //recalling is here. when I remove it, problem has gone.
}
else
{

...
}
}

希望这对您有所帮助。

关于android - 调用 Toast 时发生未知膨胀错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12483841/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com