zoukankan      html  css  js  c++  java
  • titanium开发教程0406修改row页眉和页脚

    1

    app.js

    // this sets the background color of the master UIView (when there are no windows/tab groups on it)
    Titanium.UI.setBackgroundColor('#000');
    
    // create tab group
    var tabGroup = Titanium.UI.createTabGroup();
    
    var win = Titanium.UI.createWindow({  
        title:"Tours",
        backgroundColor:"#FFFFFF",
        //navBarHidden:true, //Hide the nav bar for the window
        tabBarHidden:true //Hide the tab bar for the window
    });
    //Remember, we are hiding this tab through the property tabBarHidden above
    var tab = Titanium.UI.createTab({  
        icon:"KS_nav_views.png",
        title:"Tours",
        window:win
    });
    
    var data = [
    	{title:"Backpack Cal", leftImage:"images/01-backpack-cal-thumb.png", className:"tableRow", header:"B"},
    	{title:"California Calm", leftImage:"images/02-calm-cal-thumb.png", className:"tableRow", hasDetail:true, customData:"This is custom row data", header:"C"},
    	{title:"California Hotsprings", leftImage:"images/03-hotsprings-cal-thumb.png", className:"tableRow"},
    	{title:"Cycle California", leftImage:"images/04-cycle-cal-thumb.png", className:"tableRow"},
    	{title:"From Desert to Sea", leftImage:"images/05-desert-cal-thumb.png", className:"tableRow", header:"From 'F' on forward"},
    	{title:"Kids California", leftImage:"images/06-kids-cal-thumb.png", className:"tableRow", hasDetail:true, customData:"This is custom row data"},
    	{title:"Nature Watch", leftImage:"images/07-nature-watch-cal-thumb.png", className:"tableRow"},
    	{title:"Snowboard Cali", leftImage:"images/08-snowboard-cal-thumb.png", className:"tableRow",hasDetail:true,js:"external.js",dataToPass:"This data was passed in from the main window"},
    	{title:"Taste of California", leftImage:"images/09-taste-cal-thumb.png", className:"tableRow", footer:"Choose a tour and explore today"}
    ]
    
    var tableView = Titanium.UI.createTableView({
    	//4. Set the new array as the data source for our TableView
    	data:data
    });
    
    tableView.addEventListener("click",function(e){
    	//Check the row's hasDetail property
    	if(e.source.hasDetail){
    		if(e.source.js){//Does the row have a pointer to an external js file?
    			//It does: Load that file
    			var w = Titanium.UI.createWindow({
    				title:e.source.title,//Take the title from the row
    				backgroundColor:"#FFFFFF",
    				dataToPass:e.source.dataToPass,
    				url:e.source.js//The url property of a window will load an external .js file for window contents (be sure that external file is properly formatted!)
    			});
    		}else{
    			//It doesn't: Create a window from scratch
    			var w = Titanium.UI.createWindow({
    				title:e.source.title,//Take the title from the row
    				backgroundColor:"#FFFFFF",
    			})
    			//Create some views for our window
    			
    			var label = Titanium.UI.createLabel({
    				text:"A newly opened window from the " + e.source.title + " row",
    				"auto",
    				height:"auto",
    				textAlign:"center"
    			});
    			
    			w.add(label)
    		}
    		//Slide-open the window
    		tab.open(w,{animated:true});//Try it without the animated:true and see what happens
    	}else{//Row doesn't have a window to open
    		alert("No window to open :(")
    	}
    });
    
    win.add(tableView);
    
    tabGroup.addTab(tab);  
    
    // open tab group
    tabGroup.open();

    external.js

    //Create a pointer to the current window context
    var win = Titanium.UI.currentWindow;
    
    var label = Titanium.UI.createLabel({
    	text:win.dataToPass,//This text is loaded from variables passed into the window through the dataToPass property
    	"auto",
    	height:"auto",
    	textAlign:"center"
    });
    
    win.add(label);
  • 相关阅读:
    Hive on Spark
    Mongodb添加副本及修改优先级
    RabbitMQ与Spring集成
    最简单的图文教程,几步完成Git的公私钥配置
    Idea Ant 打开发包
    Spring Web 项目Junit测试报错问题
    阿里云maven仓库地址,速度提升100倍
    Spring boot 学习
    JAVA开发常用工具包
    从无到有搭建SSM框架
  • 原文地址:https://www.cnblogs.com/xiaozhanga4/p/2403279.html
Copyright © 2011-2022 走看看