Ich habe vor kurzem meine appcelerator Projekte von der 5.5.1 Titan SDK auf 6.1.0 aktualisiert.Appcelerator Titan Bug in ListView benutzerdefinierte Vorlagen auf Android
Benutzerdefinierte Vorlagen für Listenansichten auf Android verhalten sich in 6.1.1 anders als in 5.5.1 und allen früheren Versionen von Titan, die ich verwendet habe. Das Problem besteht darin, horizontale Layoutansichten innerhalb vertikaler Layoutansichten zu verschachteln.
In diesem Beispiel des Fehlers wird in einer Listenansicht der Name einer Frucht auf Englisch angezeigt. Anschließend werden die französische, deutsche und spanische Übersetzung horizontal, aber unterhalb des englischen Namens angezeigt.
Wie in den angehängten Bildern zu sehen ist, wird die iPhone Version korrekt angezeigt, aber die Android Version hat die fehlenden Übersetzungen. Titanium 5.5.1 und früher wurde auf beiden Plattformen korrekt angezeigt.
In der benutzerdefinierten Vorlage habe ich Hintergrundfarben verwendet, um zu sehen, wo jede Ansicht und jedes Etikett angezeigt wird.
Weiß jemand, warum die Untertitel in der Android-Version fehlen? Ist das ein Titan Bug oder mache ich etwas falsch?
Hier ist das iPhone Bild, das richtig angezeigt wird:
Hier ist das Android Bild, das den Untertitel hat
fehlt Hier ist die gesamte Code erforderlich, um die Android-Fehler zu reproduzieren. Stellen Sie sicher, Sie verwenden das Titanium 6.1.0 SDK
var win = Ti.UI.createWindow({backgroundColor: 'white'});
// Create a custom template that displays the English title, then three
// subtitles for French, German & Spanish laid out horizontally below the
// English title
var myTemplate = {
properties: {
height: Ti.UI.SIZE,
width: Ti.UI.FILL
},
childTemplates: [
{
type: 'Ti.UI.View',
properties: {
backgroundColor: '#fcf',
height: Ti.UI.SIZE,
layout: 'vertical',
left: 15,
right: 15,
width: Ti.UI.FILL
},
childTemplates: [
{ // English
type: 'Ti.UI.Label', // Use a label for the text
bindId: 'english', // Maps to the english property of the item data
properties: { // Sets the label properties
color: 'black',
font: { fontFamily:'Arial', fontSize: '20dp', fontWeight:'bold' },
left: 0
}
},
{ // Container for language subtitles
type: 'Ti.UI.View',
properties: {
backgroundColor: '#ffc',
height: Ti.UI.SIZE,
layout: 'horizontal', // subtitles should be laid out horiznontally
},
childTemplates: [
{ // French
type: 'Ti.UI.Label', // Use a label for the text
bindId: 'french', // Maps to the french property of the item data
properties: { // Sets the label properties
backgroundColor: 'gray',
color: 'white',
font: { fontFamily:'Arial', fontSize: '14dp' },
right: 10
}
},
{ // German
type: 'Ti.UI.Label', // Use a label for the text
bindId: 'german', // Maps to the german property of the item data
properties: { // Sets the label properties
backgroundColor: 'red',
color: 'white',
font: { fontFamily:'Arial', fontSize: '14dp' },
right: 10
}
},
{ // Spanish
type: 'Ti.UI.Label', // Use a label for the text
bindId: 'spanish', // Maps to the spanish property of the item data
properties: { // Sets the label properties
backgroundColor: 'blue',
color: 'white',
font: { fontFamily:'Arial', fontSize: '14dp' },
right: 10
}
}
]
}
]
}
]
};
// Create the list view
var listView = Ti.UI.createListView({
templates: { 'template': myTemplate },
defaultItemTemplate: 'template',
top: Ti.Platform.osname === 'iphone' ? 20 : 0 // Allow for iOS status bar
});
// Create the list data set
var fruitSection = Ti.UI.createListSection({ headerTitle: 'Fruits'});
var fruitDataSet = [
{ english: {text: 'Apple'}, french: {text: 'Pomme', visible: true}, german: {text: 'Apfel'}, spanish: {text: 'Manzana'}},
{ english: {text: 'Banana'}, french: {text: 'Banane'}, german: {text: 'Banane'}, spanish: {text: 'Plátano'}}
];
fruitSection.setItems(fruitDataSet);
// Add the data set to the list view
var sections = [fruitSection];
listView.setSections(sections);
// Add the list view to the main window and open it
win.add(listView);
win.open();
Try fruitSection.setItems (fruitDataSet) nach listView.setSections (Abschnitte) einzustellen. – Umair