简体   繁体   English

从不使用Appcelerator中的自定义ListView进行图像

[英]Never image with a custom ListView in appcelerator

I'm building an app with appcelerator that show a ListView with a custom template. 我正在使用appcelerator构建一个应用程序,该应用程序显示带有自定义模板的ListView。 So This is the code of my xml file: 所以这是我的xml文件的代码:

<ListView id="elementsList" defaultItemTemplate="elementTemplate">
            <Templates>
                <ItemTemplate name="elementTemplate" class="itemTemplate">

                    <View id="atomProperties">
                        <Label bindId="name" id="name" />
                        <View id="secondLine">
                            <Label class="line2 fieldLabel" text="from: " />
                            <Label class="line2" bindId="dateStart" id="dateStart" />
                            <Label class="line2 fieldLabel" text=" to: " />
                            <Label class="line2" bindId="dateEnd" id="dateEnd" />
                        </View>
                        <Label bindId="quantity" id="quantity" left="0"/>
                    </View>
                </ItemTemplate>
            </Templates>
            <ListSection>               
                <ListItem quantity:text="10 minute" quantity:color="#090"  name:text="Hydrogen" dateStart:text="10-10-2016" dateEnd:text="10-12-2016"/>
                <ListItem quantity:text="15 minute" quantity:color="#090" name:text="Helium" dateStart:text="02-01-2015" dateEnd:text="10-10-2019"/>
                <ListItem quantity:text="25 minute" quantity:color="#090" name:text="Lithium" dateStart:text="01-01-2001" dateEnd:text="01-01-2018"/>
                <ListItem quantity:text="10 minute" quantity:color="#090"  name:text="Hydrogen" dateStart:text="10-10-2016" dateEnd:text="10-12-2016"/>
                <ListItem quantity:text="15 minute" quantity:color="#090" name:text="Helium" dateStart:text="02-01-2015" dateEnd:text="10-10-2019"/>
                <ListItem quantity:text="25 minute" quantity:color="#090" name:text="Lithium" dateStart:text="01-01-2001" dateEnd:text="01-01-2018"/>
            </ListSection>
        </ListView> 

This is a part of my tss file: 这是我的tss文件的一部分:

"ListItem": {
    accessoryType: Titanium.UI.LIST_ACCESSORY_TYPE_DISCLOSURE
}

So if I try to start my application, I can see this: 因此,如果我尝试启动我的应用程序,则可以看到以下内容:

在此处输入图片说明

And this is ok. 没关系。 Now I want to set a ListSection with a data from a database. 现在,我想使用数据库中的数据设置ListSection。

So I'm delete from my xml file this code: 所以我要从我的xml文件中删除以下代码:

<ListItem quantity:text="10 minute" quantity:color="#090"  name:text="Hydrogen" dateStart:text="10-10-2016" dateEnd:text="10-12-2016"/>
                <ListItem quantity:text="15 minute" quantity:color="#090" name:text="Helium" dateStart:text="02-01-2015" dateEnd:text="10-10-2019"/>
                <ListItem quantity:text="25 minute" quantity:color="#090" name:text="Lithium" dateStart:text="01-01-2001" dateEnd:text="01-01-2018"/>
                <ListItem quantity:text="10 minute" quantity:color="#090"  name:text="Hydrogen" dateStart:text="10-10-2016" dateEnd:text="10-12-2016"/>
                <ListItem quantity:text="15 minute" quantity:color="#090" name:text="Helium" dateStart:text="02-01-2015" dateEnd:text="10-10-2019"/>
                <ListItem quantity:text="25 minute" quantity:color="#090" name:text="Lithium" dateStart:text="01-01-2001" dateEnd:text="01-01-2018"/>

And from my controller.js I'm building this code: 然后从我的controller.js构建以下代码:

function populateTable(){
    var collection = Alloy.createCollection("SocialHistoryDAO");
    collection.fetch();
    collection.forEach(function(e, i, a) {
        items.push({                    
            dateStart : {text : e.get("DateStart")}, 
        name : {text : e.get("DisplayName")},
        dateEnd : {text : e.get("DateEnd")}, 
        quantity : {color:"#090", text : e.get("Quantity")+" "+e.get("UnityMeasure")}               
        }); 
    });
    $.elementsList.sections[0].setItems(items);

}

If I try to start my application I can see a List View never symbol ">" at right of every Items. 如果我尝试启动我的应用程序,我将在每个项目的右侧看到一个列表视图,从不显示符号“>”。

How can I fixed it? 我该如何解决?

There are no ListItems in your code anymore, so adding styling to it won't work of course. 您的代码中再也没有ListItems了,因此添加样式当然是行不通的。

However, you can just style a Template. 但是,您可以仅设置模板样式。 So change the identifier and it should work 所以更改标识符,它应该可以工作

".itemTemplate": {
    accessoryType: Titanium.UI.LIST_ACCESSORY_TYPE_DISCLOSURE
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM