android preference tab,Android SharedPreference - TabHost问题
我正在開發Android應用程序,它有兩個不同的tabhost:Main和Child。 在主tabhost我有5個不同的標簽,最后一個打開新的活動,我有登錄頁面。我想創建一個布爾類型isLoggedIn登錄活動,并傳遞true或false到主選項卡欄,因為我想要更改如果用戶登錄,我會有5,如果沒有,我會有4個選項卡。所以,如何編碼此問題的任何建議?Android SharedPreference - TabHost問題
更新:
現在我用我用這個code.In用戶LogIn.class:
SharedPreferences isLogged = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
SharedPreferences.Editor editor = isLogged.edit();
editor.putBoolean("isLoggedIn", isLoggedIn);
editor.commit();
在MainActivity我使用幾乎相同的代碼:
SharedPreferences isLogged = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
SharedPreferences.Editor editor = isLogged.edit();
editor.putBoolean("isLoggedIn", false);
editor.commit();
我檢查兩種狀態:
if(editor.putBoolean("isLoggedIn", false) != null){
// show 5 tabs
}else
{
// show 4 tabs;
但是,當我打開我的應用程序,我得到5個選項卡,甚至在檢查用戶的狀態之前。 任何想法如何解決這個問題? }
總結
以上是生活随笔為你收集整理的android preference tab,Android SharedPreference - TabHost问题的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: android 连续调用js方法,And
- 下一篇: html css 多选下拉框,jQuer