2015-05-08 35 views
0

我想先創建一個活動,然後在2秒後,我想隱藏操作欄,然後在另一個2秒後,我想要啓動另一個活動,但此代碼 - getActionBar().hide()不起作用。這裏是我的代碼 -在開始另一個活動之前無法隱藏操作欄

@Override 
protected void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.activity_start); 

    //final ActionBar actionbar = getActionBar(); 

    Thread timer1 = new Thread() { 
     public void run(){ 
      try{ 
       sleep(2000); 
      } catch(InterruptedException e){ 
       e.printStackTrace(); 
      } finally{ 
       getActionBar().hide(); 
      } 
     } 
    }; 
    timer1.start(); 

    Thread timer2 = new Thread() { 
     public void run(){ 
      try{ 
       sleep(2000); 
      } catch(InterruptedException e){ 
       e.printStackTrace(); 
      } finally{ 
       Intent intent = new Intent("app.lost_and_found_0.STARTINGPOINT"); 
       startActivity(intent); 
      } 
     } 
    }; 
    timer2.start(); 
} 

有什麼問題我做錯了嗎? 我的應用程序主題在清單文件中設置爲Theme.Holo.Light

+0

不知道這是否有幫助,但也許只是將其設置爲一個空白的操作欄將幫助您 –

回答

0

使用getSupportActionBar()代替getActionBar()。就類而言,你需要擴展ActionBarActivity。

+0

我使用API​​ 15作爲最低限度。 – PalashV