2013-08-24 31 views
0

這是我在社區中的第一個提到鈦工作室的API的問題。我解釋說:我試圖把一個textField放在一個listView中的一個項目,但是當編譯時,什麼時候關注文本區域不會讓我寫,當它在其他類型的listView中。textField in listView

我希望你可以用這個

var win = Ti.UI.createWindow({ 
    backgroundColor:'#FFF' 
}); 

var plainTemplate = { 
    childTemplates: [ 
     {        
      type: 'Ti.UI.Label', 
      bindId: 'title',   
      properties: {    
       width: '100%', 
       height: 30, 
       left: 0, 
       top:0 
      } 
     }, 

     { 
      type: 'Ti.UI.TextArea', 
      bindId: 'campo', 
      properties: { 
       top:60, 
       width: '70%', 
       left:10, 
       height:40 
      } 
     } 

    ], 

    events: {click: check } 
}; 

var listView = Ti.UI.createListView({ 
    templates: { 'uncheck': plainTemplate}, 
    defaultItemTemplate: 'uncheck' 
}); 

var data = []; 
for (var i = 0; i < 20; i++) { 
    data.push({ 

     title : { text: 'row' + i }, 

     properties : { 
      itemId: 'row' + i, 
      accessoryType: Ti.UI.LIST_ACCESSORY_TYPE_NONE, 
     } 
    }); 
} 

var section = Ti.UI.createListSection(); 
section.setItems(data); 
listView.sections = [section]; 

function check() { 
    alert('estas aqui!!'); 
} 

win.add(listView); 

win.open(); 
+0

你能顯示你使用的代碼嗎? –

+0

只是試着把你的代碼放在這裏,以便我可以幫助你。你問的是不足以回答.. –

+0

我不太確定這一點。但似乎你指的是相同的變量是plainTemplate,所有列表視圖項目。嘗試使用函數每次創建新的文本字段。 – chanaka777

回答

0

你已經嘗試了刪除頂級物業中60像素的UITextArea幫助嗎?這可能是原因,爲什麼你的textarea的是在其他的位置,你所預期的:

{ 
     type: 'Ti.UI.TextArea', 
     bindId: 'campo', 
     properties: { 
      // top: 60 <--- remove that line 
      width: '70%', 
      left:10, 
      height:40 
     } 
    } 

我沒有測試你的整個代碼,但在我的應用程序增加了一個頂級屬性與此值到ListView我在哪裏工作,它以你寫的類似行爲結束。