Titanium Android:视图未附加到窗口管理器崩溃 [英] Titanium Android: View not attached to window manager chrash

查看:24
本文介绍了Titanium Android:视图未附加到窗口管理器崩溃的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个视图.在第一个视图中,我有一个表视图,我在其单元格中显示远程数据.我在下载数据时显示活动指示器.

I have two views.In first view, I have a table view and I am displaying remote data in its cells. I am showing activity indicator while data downloading.

选择任何行时打开第二个视图.

Second view gets open when any of row is selected.

当我回到第一个视图时,我正在通过下载远程数据刷新表视图.

When I come back to the first view, I am refreshing the table view by downloading remote data.

但是在 Android 中,当我回到第一个视图并开始下载数据时,由于活动指示器,应用程序崩溃!!!应用程序仅在 Android 中崩溃,在 iPhone 中运行良好!

But in Android, when I come back to first view and start downloading data, application gets crash due to activity indicator !!! Application crashes only in Android, its working fine in iPhone !!

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

I am refreshing the table's data in focus event of current window.

错误:-

Activity org.appcelerator.titanium.TiActivity 有泄露窗口com.android.internal.policy.impl.PhoneWindow$DecorView@450c4488最初在这里添加 E/WindowManager(324):android.view.WindowLeaked:活动org.appcelerator.titanium.TiActivity 有泄露的窗口com.android.internal.policy.impl.PhoneWindow$DecorView@450c4488最初是在这里添加的

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] 发送事件:线程异常:mainmsg:java.lang.IllegalArgumentException: 视图未附加到窗口经理;钛 1.8.1,2012/01/27 17:31,a24502a E/TiApplication(324):java.lang.IllegalArgumentException:视图未附加到窗口经理

(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 中,当您按下后退按钮时,它无法正确导航到上一个视图.它只是显示以前的视图,而不关心当前视图.

Solved !!! I found that, in Android, when you press back button, it doesn't handle proper navigation to the previous view. It simply displays previous view without take care of current view.

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

So it necessary to close current view properly before displaying another view. So I closed current view before displaying the previous view.

当我们在Android上按下返回按钮时,Windowandroid:back事件得到调用.所以我用这个方法关闭了当前窗口,比如:

When we press back button on Android, android:back event of Window get call. So I closed current window in this method , like :

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

这篇关于Titanium Android:视图未附加到窗口管理器崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆