Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/108.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 钛:是否将ActivityIndicator添加到listView?_Ios_Listview_Titanium_Selectlistitem_Activity Indicator - Fatal编程技术网

Ios 钛:是否将ActivityIndicator添加到listView?

Ios 钛:是否将ActivityIndicator添加到listView?,ios,listview,titanium,selectlistitem,activity-indicator,Ios,Listview,Titanium,Selectlistitem,Activity Indicator,是否可以以及如何将ActivityIndicator添加到listView listItem?可能通过选定项目上的listView模板 提前谢谢 是的,这是可能的,这里有一个片段: 首先从定义列表项模板开始: // Some text row var someTextTemplate = { properties: { accessoryType: Ti.UI.LIST_ACCESSORY_TYPE_NONE }, childTemplates: [ /

是否可以以及如何将ActivityIndicator添加到listView listItem?可能通过选定项目上的listView模板


提前谢谢

是的,这是可能的,这里有一个片段:

  • 首先从定义列表项模板开始:

    // Some text row 
    var someTextTemplate = {
        properties: {
            accessoryType: Ti.UI.LIST_ACCESSORY_TYPE_NONE
        },
        childTemplates: [ // Add view subcomponents to the ListItem
            {
                // Display a Label
                type: 'Ti.UI.Label',
                bindId: 'someRowText',
                properties: {
                    font: {fontSize: '14dp'}
                }
            }
        ]
    };
    
    //This is your loading template
    var loadingTemplate = {
        properties: {
            accessoryType: Ti.UI.LIST_ACCESSORY_TYPE_NONE
        },
        childTemplates: [ //And here is where the activity indicator goes
        {
            // Display an activity indicator
            type: 'Ti.UI.ActivityIndicator',
            // If there is a 'loadingIndicator' dictionary in the ListDataItem,
            // that data binds with this view subcomponent (useful for changing
            // the loading message, for example)
            bindId: 'loadingIndicator', 
            properties: {
                // Set the indicator properties
                font: { fontSize: '22dp'},
                width: Titanium.UI.SIZE,
                height: Titanium.UI.SIZE,
                // If you don't set visible to true, the indicator will not show,
                // because unlike other UI elements, it is hidden by default
                visible: true, 
                //Other styles available, just check the component doc      
                style: Titanium.UI.iPhone.ActivityIndicatorStyle.PLAIN
            }
        }
        ]
    };
    
  • 然后设置ListView

    // Create the list section
    var listSection = Titanium.UI.createListSection();
    
    // Add the list section to a list view
    var listView = Titanium.UI.createListView({
        width: Ti.UI.FILL,
        height: Ti.UI.SIZE,
        layout: 'vertical',
        touchEnabled: true,
        sections: [listSection],
        templates: {'rowText': someTextTemplate, 'loading': loadingTemplate },
        defaultItemTemplate: 'rowText',
        showVerticalScrollIndicator: true
    });
    
  • 最后,添加一些列表数据项

    var someData = [];
    // This will add a row with a label, because we've set 'rowText' as our 
    // default ListView template
    someData.push({
        someRowText: { text: 'Some text row 1'}
    });
    // This will also show another label row, because we're specifying 
    // the template to use, in this case the label one
    someData.push({
        someRowText: { text: 'Some text row 2'},
        template: 'rowText'
    });
    // Now we're going to use the 'loading' template, therefore showing 
    // the activity indicator in the row
    someData.push({
        loadingIndicator: { message: 'Please wait while transfering data from the mothership...' },
        template: 'loading'
    });
    
    //Add our data items to the listview section
    listSection.setItems(someData);
    

  • 您也可以混合使用多个模板,但我已尝试尽可能简化示例。

    好的,可能只是,可能吗?有人试过吗?