symbian 傳統模式下 應用程式中的視圖切換問題

來源:互聯網
上載者:User

by chenziteng

 

 

最簡單的辦法是通過CCoeControl::MakeVisible()函數改變Container的可見度:  
   
  1.   在AppUi::ConstructL()裡建立兩個Container類的執行個體,並調用AddToStackL()將它們加入到Constrol   Stack中,然後隱藏暫時不顯示的Container  
   
  void   CMyAppUi::ConstructL()  
          {  
          BaseConstructL();  
   
          iContainer1   =   CMyContainer1::NewL(ClientRect());  
          iContainer2   =   CMyContainer2::NewL(ClientRect());  
          AddToStackL(iContainer2);  
          AddToStackL(iContainer1);  
   
          iContainer2->MakeVisible(EFalse);  
          }  
   
  2.在接收到命令後切換兩個Container的可見度  
   
  void   CMyAppUi::HandleCommandL(TInt   aCommand)  
          {  
          switch(aCommand)  
                  {  
                  case   ESwitchToContainer2:  
                          {  
                          iContainer2->MakeVisible(ETrue);  
                          iContainer1->MakeVisible(EFalse);  
                          break;  
                          }  
                  case   EEikCmdExit:  
                  case   EAknSoftkeyExit:  
                          {  
                          Exit();  
                          break;  
                          }  
                  default:  
                          {  
  //                         Panic(EHelloWorldBasicUi);  
                          break;  
                          }  
                  }  
          }  
   
  3.   在AppUi的解構函式中調用RemoveFromStackL()將兩個Container從Control   Stack中移除並delete掉。  
  CMyAppUi::~CHelloWorldAppUi()  
          {  
          if   (iContainer1)  
                  {  
                  RemoveFromStack(iContainer1);  
                  delete   iContainer1;  
                  }  
          if   (iContainer2)  
                  {  
                  RemoveFromStack(iContainer2);  
                  delete   iContainer2;  
                  }                  
          }  
   
    另一個辦法是一開始只建立Container1,等用到Container2時再建立Container2,並銷毀Container1

 

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.