2015-12-31 38 views
2

我正在使用下面的代碼更改區域設置。這已經是一天試圖改變我的場所,但還沒有成功。強制區域設置不會影響工具欄的內容

Locale locale; 

    public void changeLanguage(Locale localeChanger){ 
     locale=localeChanger; 
     Resources res = getResources(); 
     DisplayMetrics displayMetrics = res.getDisplayMetrics(); 
     Configuration conf = res.getConfiguration(); 
     conf.locale = locale; 
     res.updateConfiguration(conf, displayMetrics); 

     Intent refreshStartPage = new Intent(this, StartPage.class); 
     startActivity(refreshStartPage); 
     recreate(); 
    } 

,在這裏我的工具欄的XML代碼

<android.support.v7.widget.Toolbar 
     android:id="@+id/page_toolbar" 
     android:layout_width="match_parent" 
     android:layout_height="?attr/actionBarSize" 
     android:background="?attr/colorPrimary"> 

<TextView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="title" 
     android:id="@+id/my_toolbar_title" /> 

</android.support.v7.widget.Toolbar> 

回答

-1

擺脫文本行的工具欄佈局

android:text="title" 

內再加入

setTitle (R.string.name_here) 

工具欄初值法裏面。希望,你有你想要的。

相關問題