gpt4 book ai didi

android - 钛安卓 : View not attached to window manager chrash

转载 作者:行者123 更新时间:2023-11-30 04:17:13 28 4
gpt4 key购买 nike

我有两个 View 。在第一个 View 中,我有一个 TableView ,我在其单元格中显示远程数据。我在下载数据时显示 Activity 指示器。

当选择任何行时,第二个 View 会打开。

当我回到第一个 View 时,我正在通过下载远程数据来刷新 TableView 。

但在 Android 中,当我返回第一个 View 并开始下载数据时,应用程序会因 Activity 指示器而崩溃!!!应用程序仅在 Android 中崩溃,在 iPhone 中运行正常!!

我在当前窗口的 focus 事件中刷新表格的数据。

错误:-

Activity org.appcelerator.titanium.TiActivity has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView@450c4488 that was originally added here E/WindowManager( 324): android.view.WindowLeaked: Activity org.appcelerator.titanium.TiActivity has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView@450c4488 that was originally added here

(main) [2225,140482] Sending event: exception on thread: main msg:java.lang.IllegalArgumentException: View not attached to window manager; Titanium 1.8.1,2012/01/27 17:31,a24502a E/TiApplication( 324): java.lang.IllegalArgumentException: View not attached to window manager

已编辑

我的代码:-

var currentWindow = Titanium.UI.currentWindow;

var placeTableData = [] ;
var placeTableView = Titanium.UI.createTableView
({
data:placeTableData,
top:'0dp',
height:'365dp'
});

currentWindow.addEventListener('focus',winopened);
function winopened(e)
{
placeTableData = createRow();
}

function createRow()
{
currentWindow.add(activity);
activity.show();
currentWindow.touchEnabled = false;

// downloading data

if(loader1.DONE)
{
currentWindow.touchEnabled = true ;
activity.hide();
}
}

最佳答案

解决了!!!我发现,在 Android 中,当您按下后退按钮时,它无法正确导航到上一个 View 。它只显示以前的 View ,而不考虑当前 View 。

因此有必要在显示另一个 View 之前正确关闭当前 View 。所以我在显示前一个 View 之前关闭了当前 View 。

当我们在 Android 上按下后退按钮时,Windowandroid:back 事件会被调用。所以我用这个方法关闭了当前窗口,比如:

Titanium.UI.currentWindow.addEventListener('android:back',function(e)
{
Ti.API.info('back button pressed');
currentWindow.close();
});

关于android - 钛安卓 : View not attached to window manager chrash,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9802302/

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