Я разрабатываю приложение с инфраструктурой Appcelerator (используя Appcelerator Studio), но столкнулся с проблемой без решения (пока).
Я создаю список со всеми странами мира и соответствующими им телефонными префиксами, т. е. «США +1», «Великобритания +44» и так далее. Я использую ListView, так как пользователю придется выбирать один. В iOS все работает отлично, но когда я запускаю приложение на своем физическом устройстве Android, присутствуют все ListItems, но не их текст. Я имею в виду, что в iOS я вижу все страны и соответствующие им названия в каждой строке. В Android я вижу, что в моем ListView более 150 строк, я могу щелкнуть по этим строкам, приложение выберет соответствующую страну, но я не вижу печатного текста в строках.
Я использую ItemTemplate, а затем создаю (с помощью Javascript) ListSection, в который добавляю элементы (добавляя их динамически с помощью свойства bindId).
Я видел, что другие приложения, созданные с помощью Appcelerator, не имеют этой проблемы, поэтому я пытаюсь понять, где я ошибаюсь.
countryList.xml
<Alloy>
<Window class="container" id="win_firstStart_countryList">
<ListView id="ListView_prefixes">
<SearchBar id="searchBar_countries"/>
<Templates>
<ItemTemplate id="countryCodeTempl" name="countryCodeTempl">
<Label id="label_countryName"/>
<Label id="label_countryPrefix"/>
</ItemTemplate>
</Templates>
</ListView>
</Window>
</Alloy>
countryList.tss
"#ListView_prefixes": {
"left": "0.00%",
"top": "0%",
"defaultItemTemplate": "countryCodeTempl"
},
"#countryCodeTempl": {
"color": "#000000",
"backgroundColor": "#000000",
},
"#label_countryName": {
"color": "#000000",
"font": {fontSize:'18dp',fontFamily:'',fontStyle:'',fontWeight:''},
"left": "3%",
"top": "4dp",
"bindId": "countryName",
"height": Ti.UI.SIZE,
"width": "45%",
"backgroundColor": "#ff0000",
},
"#label_countryPrefix": {
"bindId": "countryPrefix",
"top": "4dp",
"width": "45%",
"height": Ti.UI.SIZE,
"color": "#000000",
"font": {fontSize:'18dp',fontFamily:'',fontStyle:'',fontWeight:''},
"right": "3%",
"textAlign": "right"
},
"#win_firstStart_countryList": {
"left": "0.00%",
"top": "0%",
"height": "100%",
"width": "100.00%",
"backgroundColor": "#ffffff",
}
countryList.js
var countrySection = Ti.UI.createListSection({});
var items = [];
var db = Ti.Database.open(DB_NAME);
var query = db.execute("SELECT country_code, country_name, country_prefix from countries");
while (query.isValidRow()) {
items.push({
countryName: { text: query.fieldByName('country_name') },
countryPrefix: { text: "+ " + query.fieldByName('country_prefix') },
properties: {
title: query.fieldByName('country_name'),
itemId: query.fieldByName('country_code'),
searchableText: query.fieldByName('country_name'),
caseInsensitiveSearch: true
}
});
query.next();
}
query.close();
db.close();
countrySection.setItems(items);
$.ListView_prefixes.sections = [countrySection];
$.ListView_prefixes.searchView = $.searchBar_countries;
$.searchBar_countries.addEventListener('change', function(e){
$.ListView_prefixes.searchText = e.value;
});
У вас есть идеи, почему я не вижу countryName
и countryPrefix
внутри моих элементов списка только на устройствах Android?