2016-07-02 27 views
0

我有項目中的按鈕列表視圖。我設置了一個單擊事件函數,但它不返回單擊的按鈕屬性。在iOS中,它工作正常。如何獲取按鈕在列表視圖中單擊的源屬性? [Andorid Appcelerator]

var item = { 
    properties : { 
     accessoryType: Ti.UI.LIST_ACCESSORY_TYPE_NONE, 
     backgroundColor: '#fff', 
     width: Ti.UI.FILL, 
     height : Ti.UI.SIZE 
    }, 
    events: { 
     click: eventFunction 
    }, 
    childTemplates : [ 
    { 
     type : 'Ti.UI.Button', 
     bindId : 'bindButton', 
     properties : { 
      width: 70, 
      height: 70, 
      image: "/images/user_icon.png", 
      borderRadius: 35, 
      borderWidth: 1, 
      borderColor: '#dedede', 
      zIndex: 1, 
      backgroundColor: 'transparent', 
      idButton : 10 
     } 

當我點擊eventFunction中的按鈕時,我希望找到e.source.idButton,但e.source不包含它。爲什麼?在iOS中,我發現預期的屬性。 我已經嘗試移動按鈕模板中的事件參數,但結果是相同的。

回答

0

在我的listview我只聽「itemclick」事件。 所以我當前的代碼是這樣的:

listView.addEventListener('itemclick',function(e){ 
    var item = listView.getSections()[0].getItemAt(e.itemIndex); 
    if(e.bindId === 'blockIcon'){ 
     //do my stuff 
    } 

讓我知道如果這能幫助你

+0

您好,感謝您的留言。在我的情況下,這是行不通的,因爲我有dinatures生成的n個按鈕,並獲得每次點擊的屬性是必要的知道我點擊了哪個按鈕。 – Lorenzo

相關問題