2016-01-29 147 views
-2

我使用這個代碼從谷歌隱藏操作欄,但是當我跑,我的應用程序停止,並拋出錯誤隱藏操作欄或更高

不幸的是,你的應用程序已經停止。

View decorView = getWindow().getDecorView(); 
int uiOptions = View.SYSTEM_UI_FLAG_FULLSCREEN; 
decorView.setSystemUiVisibility(uiOptions); 
ActionBar actionBar = getActionBar(); 
actionBar.hide(); 
+0

請發表您的logcat的錯誤跟蹤。 – Rohit5k2

+0

replace getActionBar(); getSupportActionBar(); –

+0

你會請把logcat輸出關於錯誤 – Abhishek

回答

0

步驟1後logcat的消息:更換

ActionBar actionBar = getActionBar(); 

ActionBar actionBar = getSupportActionBar(); 
+0

我有另一個問題,當我檢查互聯網連接或不是我的應用程序停止並顯示警報「不幸的是,你的應用程序已停止。」 我的代碼 boolean isConnect = false; ConnectivityManager cm =(ConnectivityManager)getSystemService(Context.CONNECTIVITY_SERVICE); if(cm!= null)NetworkInfo activeNetwork = cm.getActiveNetworkInfo(); (activeNetwork!= null){ isConnect = activeNetwork.isConnectedOrConnecting(); return isConnect; } } return false; –

0

如果您正在使用的主題爲 「NoActionBar」 然後getActionBar()將返回null。 請了解更多詳情