【问题标题】:Surface is not valid on android appSurface 在 Android 应用上无效
【发布时间】:2014-10-29 09:46:07
【问题描述】:

appcelerator 专家您好,

我目前正在编写一个带有 3 个窗口(合金)的简单应用程序。按下按钮时,窗口会依次显示,因此窗口 1 会显示一个按钮 -> 转到窗口 2 -> 按其按钮 -> 窗口 3。使用后退按钮可以返回上一个窗口。

问题是应用程序有时会在窗口之间切换时崩溃并重新启动,并产生错误“ViewRootImpl #2 Surface is not valid”,我不知道如何解决。任何曾经见过这个问题或猜测可能是什么问题的人?也许事件监听器经常被删除?

应用类型:移动 钛 SDK:3.4.0.GA 平台和版本:Android 4.1 设备:物理安卓设备 主机操作系统:Mac OSX Yosemite 钛工作室:3.4.0.201409261227 构建:jenkins-titanium-rcp-master-197

查看(index.xml):

<Alloy>


<Window id="intro_android" class="container">
    <View id="vdescription">
        <Label id="description1">Do you like discovering new restaurants, eating nice food AND saving money?</Label>
        <Label id="description2">The Food Fairy will help you!</Label>
        <Label id="description3">You will receive notifications like this:</Label>
        <ImageView id="screenshot" image="/images/screenshot.png"></ImageView>
    </View>
    <View class="vbutton">
        <Button id="getstarted" ></Button>  
    </View>
</Window>   

<Window id="usage_android" class="container">
    <View id="vsaved">
        <Label id="text_saved">You currently saved:</Label>
        <Label id="amount_saved">00.00 €</Label>
    </View>
    <View id="vranking">
        <TableView id="table">
            <TableViewSection>
                <TableViewRow class="row1"><Label class="number_ranking">1.</Label><Label class="name_ranking">John</Label><Label class="amount_ranking">637.02 €</Label></TableViewRow>
                <TableViewRow class="row2"><Label class="dots_ranking">...</Label></TableViewRow>
                <TableViewRow class="row3"><Label class="number_ranking">524.</Label><Label class="name_ranking">Mary</Label><Label class="amount_ranking">00.81 €</Label></TableViewRow>
                <TableViewRow class="userrow_ranking"><Label id="usernumber_ranking">525.</Label><Label id="username_ranking">YOU</Label><Label id="useramount_ranking">00.00 €</Label></TableViewRow>
                <TableViewRow class="row4"><Label class="number_ranking">526.</Label><Label class="name_ranking">Sarah</Label><Label class="amount_ranking">00.00 €</Label></TableViewRow>
                <TableViewRow class="row5"><Label class="dots_ranking">...</Label></TableViewRow>
            </TableViewSection>
        </TableView>
    </View>
    <View class="vbutton">
        <Button id="gethelp" ></Button> 
    </View>
</Window>

<Window id="help" class="container">
    <ScrollView id="vhelp">
        <Label id="help_text1">Heres more information:</Label>
        <Label class="help_text2">The Food Fairy finds the best food deals close to you! To help you find a place close-by to grab a bite on a budget, the fairy will send you a notification when you approach a restaurant offering a special deal.</Label>
        <Label class="help_text2">Because shes magic (duh), she doest need your app to be open and doesnt use GPS; she will know where you are, where the deals are, and will let you know when your paths cross.</Label>
    </ScrollView>
</Window>

</Alloy>

控制器(index.js):

function start_android(e) {
$.usage_android.open();
}

function start_ios(e) {
$.usage_ios.open();
}

function start_help(e) {
$.help.open();
}

感谢您的帮助!

【问题讨论】:

    标签: android view titanium appcelerator


    【解决方案1】:

    对于任何有类似问题的人,我已经通过将按钮移到他们的视图之外来解决它:

    <View class="vbutton">
        <Button id="getstarted" ></Button>  
    </View>
    

    进入:

        <Button id="getstarted" ></Button>  
    

    【讨论】:

    • 我知道你解决了你的问题。但是,如果您的项目很小,那么这里给您一个建议,但在这里您在单个文件中创建 3 个窗口,这种方式并不好。如果您创建任何大型项目,请始终在不同的文件中创建每个窗口,以便更好地理解。谢谢
    猜你喜欢
    • 1970-01-01
    • 2012-10-19
    • 2017-03-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-05-24
    相关资源
    最近更新 更多