2017-06-14 13 views
0

私は最近、appceleratorプロジェクトを5.5.1チタンSDKから6.1.0にアップグレードしました。Appcelerator AndroidのListViewカスタムテンプレートのバグ

Androidのリストビューのカスタムテンプレートは、6.1.1と、5.5.1でどのように動作していたのか、それまで使用していたすべての以前のバージョンのチタンとは異なります。問題は、垂直レイアウトビュー内に水平レイアウトビューを入れ子にすることです。

このバグの例では、リストビューはフルーツの名前を英語で表示し、フランス語、ドイツ語、スペイン語の翻訳を横に英語の名前の下に表示します。

添付の画像に見られるように、iPhoneのバージョンは正しく表示されますが、Androidのバージョンには翻訳がありません。 Titanium 5.5.1以前は両方のプラットフォームで正しく表示されていました。

カスタムテンプレートでは、背景色を使用して、各ビューとラベルが表示される場所をわかりやすくしました。

Android版で字幕が表示されないのはなぜですか?これはチタンバグですか、何か間違っていますか? enter image description here

ここenter image description here

ここでAndroidのバグを再現するために必要なすべてのコードがありますが不足して字幕を持っているAndroidのイメージがあります:

はここで正しく表示されるiPhoneの画像です。あなたはチタン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(); 
+0

でこれを修正した使用を確認することはlistView.setSections(セクション)の後fruitSection.setItems(fruitDataSet)を設定してください。 – Umair

答えて

0

AppceleratorのチタンSDK 6.1.1.v20170615113917

関連する問題