2013-06-11 58 views
0

我正在使用Titanium Studio構建Titanium Android移動應用程序,構建:3.1.2.201306061831並在HTC EVO上進行測試並在我的MacBook Pro 10.7.5上構建它。在窗口中交換視圖

這是一個選項卡式應用程序,當選中選項卡時,會出現一個包含選擇行的tableview,當選中某行時,會將URL發送到遠程服務器和數據庫,以便檢索JSON數據。

我有這個工作,通過在兩個單獨的文件中創建HTTP客戶端並在桌面視圖頂部的新窗口中顯示JSON。這工作,但我的標籤不可見。

我讀到我應該試着隱藏並在標籤窗口中顯示視圖。第一個視圖正確顯示,然後選擇一行時,視圖不再可見,但新視圖永遠不會顯示。我是這樣做的:

var tableview = Ti.UI.createTableView({ 
    backgroundColor:'transparent', 
    top:'50dp', 
    visible:'true', 
    color: '#000', 
    contentHeight:'auto'} 
); 
//My table code 
tableview.addEventListener('click', function(e) 
    { 
     if(checkInternetConnection()){  
       tableview.visible='false';   
        var communityview=Ti.UI.createView({ 
        top:'10dp' 
    }); 
    communityview.visible='true'; 
//Create the HTTPClient 
//add everything to communityview and add communityview to the window 

我搞砸了我是如何做我的代碼?

+0

'tableview.visible'應一個布爾值不串,同爲'communityview.visible ' – slash197

回答

0

代碼中存在一個小錯誤。 TiUIView的property visible是一個布爾值。在你的代碼中,你使用single quotes(')作爲字符串值。如果去掉單引號和重寫代碼的代碼將正常工作如下

var tableview = Ti.UI.createTableView({ 
    backgroundColor:'transparent', 
    top:'50dp', 
    visible:true, 
    color: '#000', 
    contentHeight:'auto'} 
); 
//My table code 
tableview.addEventListener('click', function(e) 
{ 
    if(checkInternetConnection()){  
     tableview.visible=false;   
     var communityview=Ti.UI.createView({ 
     top:'10dp' 
    }); 
    communityview.visible=true; 
    } 
}); 

我希望這有助於你

+0

我最終使用了'tableview.hide();'''和'communityview.show();'謝謝阿南德。 – dnevels

+0

不客氣:) – Anand