Android 删除导致应用程序在Tianium中崩溃的视图
我在钛合金屏幕上工作,屏幕上有两个输入文本字段和标签,还有一个继续按钮。在“继续”按钮单击中,我删除了变量“container”,并添加了具有不同文本字段的不同容器等。这一切都非常基本,但在“继续”按钮单击事件中,我会随机崩溃,可能有60-70%的时间会崩溃。它报告的错误只是消息“不幸已关闭”。你知道它可能是什么吗?继续下面的按钮事件监听器,当我在调试模式下运行时,我将达到崩溃3。日志似乎表明我拒绝了权限,但实际上我所做的只是用不同的视图替换一个视图。我被难住了:Android 删除导致应用程序在Tianium中崩溃的视图,android,view,titanium,Android,View,Titanium,我在钛合金屏幕上工作,屏幕上有两个输入文本字段和标签,还有一个继续按钮。在“继续”按钮单击中,我删除了变量“container”,并添加了具有不同文本字段的不同容器等。这一切都非常基本,但在“继续”按钮单击事件中,我会随机崩溃,可能有60-70%的时间会崩溃。它报告的错误只是消息“不幸已关闭”。你知道它可能是什么吗?继续下面的按钮事件监听器,当我在调试模式下运行时,我将达到崩溃3。日志似乎表明我拒绝了权限,但实际上我所做的只是用不同的视图替换一个视图。我被难住了: var self = Ti.U
var self = Ti.UI.createWindow({
title:title,
backgroundColor:'#33336F'
});
var Container=Ti.UI.createView({
top:'40dp',
width:'100%'
});
var Container2=Ti.UI.createView({
top:'40dp',
width:'100%'
});
Continue_btn.addEventListener('click', function (e){
console.log('--------------------- '+ self);
console.log('--------------------- Title_textfield val is '+Title_textField.value);
console.log('--------------------- Trade_picker val is '+Trade_picker.getSelectedRow(0).title);
console.log('--------------------- Urgent_image val is '+Urgent_image.image);
Post_array.push({
Title:Title_textField.value,
Trade:Trade_picker.getSelectedRow(0).title,
Urgency:(Urgent_image.image == "urgentChecked1.png")?"0":"1",
ClientID:8
});
console.log("--------------- Post_array is " + Post_array[0].Title+' - '+ Post_array[0].Trade + ' - ' + Post_array[0].Urgent);
console.log('-------- crash 1');
Continue_btn.setBackgroundImage('/images/continue2.png');
console.log('-------- crash 2');
console.log("Is self val undefined ------ "+ self.value + " or is Container val undefined ----- "+ Container.value + " or is container 2 val unndefined ------ "+ Container2.value);
console.log("Is self typeof undefined ------ "+ typeof self + " or is Container typeof undefined ----- "+ typeof Container + " or is container 2 typeof unndefined ------ "+ typeof Container2);
self.remove(Container);
console.log('-------- crash 3');
self.add(Container2);
console.log('-------- crash 4');
Navbar.add(BackArrow_btn);
console.log('-------- crash 5');
});
日志
[INFO][TiAPI (30736)] -------- crash 1
[INFO][TiAPI (30736)] -------- crash 2
[INFO][TiAPI (30736)] Is self val undefined ------ undefined or is Container val undefined ----- undefined or is container 2 val unndefined ------ undefined
[INFO][TiAPI (30736)] Is self undefined ------ object or is Container undefined ----- object or is container 2 unndefined ------ object
[DEBUG][SensorManager(30736)] unregisterListener:: Trklfufi 9 budiwrd5mrfo5WirfulblrwuFmfulTrklfufi$KfukwiFmfulTrklfufiRvht@,)-.d--(
[DEBUG][Sensors (30736)] Remain listener = Sending .. normal delay 200ms
[INFO][Sensors (30736)] sendDelay --- 200000000
[INFO][SensorService( 2030)] info.selectDelay() ns=20000000
[DEBUG][SensorService( 2030)] SensorDevice::setDelay, Return(true 1, false 0) = 1
[DEBUG][SensorManager(30736)] JNI - sendDelay
[INFO][SensorManager(30736)] Set normal delay = true
[DEBUG][SensorService( 2030)] SensorDevice::activating sensor handle=0 ns=20000000
[INFO][TiAPI (30736)] -------- crash 3
F/libc (30736): Fatal signal 11 (SIGSEGV) at 0x0000000c (code=1), thread 30755 (KrollRuntimeThr)
[WARN][IInputConnectionWrapper(30736)] getSelectedText on inactive InputConnection
[WARN][IInputConnectionWrapper(30736)] setComposingText on inactive InputConnection
[WARN][IInputConnectionWrapper(30736)] getExtractedText on inactive InputConnection
编辑更新了事件侦听器和日志信息。除了标签声明、文本字段和选择器添加到container视图和container2视图之外,我没有太多其他代码要包含,您是否检查了self的值?您是否尝试通过变量名而不是self将容器删除并添加到主视图中
//in Alloy
$.viewMain.remove( ... );
$.viewMain.add( ... );
//or JS
var viewMain = Ti.UI.createView(...);
viewMain.remove( ... );
self是我导出的窗口的名称,我的窗口结构为模块。我打印出self.value,它表示未定义。我的窗口变量是否应该有一个“值”?是的,检查它是否分配正确和已填充;您可以将这部分代码放在这里,以便更好地理解issuethanks以获得回复!我已按要求更新了问题。从我在打印出typeof self和typeof container 1和2时更新的日志中可以看出,我收到了“object”,因此变量本身没有定义,但对象的实际值属性没有定义。你知道如何修复吗?当我说value时,我不是指value属性,所以你检查了的类型,它有值,你是否尝试将self更改为其他名称,因为self在JS中是保留名称