2

画面の向きを変更すると、アプリケーション ラベルのフォントを保持できません。現在、SherlockFragmentActivity の onCreate メソッドで以下のコードを使用してフォントを設定しています。

titleId = Resources.getSystem().getIdentifier("action_bar_title", "id", "android");
if(titleId == 0)
    titleId = com.actionbarsherlock.R.id.abs__action_bar_title; 
mAppName = (TextView) findViewById(titleId);
Typeface face = Typeface.createFromAsset(getAssets(), "fonts/handsean.ttf");
mAppName.setTypeface(face);

向きを変更すると、フォントがデフォルトに戻ります。manifest.xml を使用して状態を保存しようとしましたが、役に立ちませんでした。ラベルのフォント以外はすべて保持されます。誰かがこれを行う方法を提案できますか?

この記事に立ち寄って読んでくれてありがとう。

4

2 に答える 2

1

android:configChanges="orientation"で向きの変更を設定して処理しようとしましたonConfigurationChanged()か?

編集:機能しない理由についてもここで説明しました。

于 2013-02-14T22:51:33.927 に答える
0
**Yes we can do this.

Override onConfigurationChanged
set the action bar title inside a handler with a delay of 200.**

@Override
    public void onConfigurationChanged(Configuration newConfig) {
        super.onConfigurationChanged(newConfig);
        new Handler().postDelayed(new Runnable() {

            @Override
            public void run() {
                //your code to set the action bar title
                setActionBarTitle(title);
            }
        }, 200);
    }
于 2015-04-29T13:09:40.553 に答える