0

私は ActionBarSherlock を使用しており、アプリケーションの多くのフラグメントで setTitle メソッドを使用しています。次に例を示します。

getActivity().setTitle(articleName);

しかし、私は ActionBar にカスタム スタイルを使用しており、タイトルを変更するときに TextView で変更したいと考えています。

<?xml version="1.0" encoding="utf-8"?>

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
              android:layout_width="match_parent"
              android:layout_height="match_parent">

    <TextView
            android:layout_width="wrap_content"
            android:layout_height="fill_parent"
            android:gravity="center"
            android:textColor="@color/grey"
            android:id="@+id/bar_title"
            style="@style/Text.Medium">
    </TextView>

</LinearLayout>

おそらく、setTitle をオーバーライドして独自のコードを追加することは可能ですか?

4

1 に答える 1

0

メソッドは最終的なものではないため、setTitleメソッド内でオーバーライドしActivityてから、 内から使用できますFragment

于 2012-09-06T12:59:36.310 に答える