ActionBarSherlock不显示标题

时间:2013-06-04 23:09:24

标签: android-fragments actionbarsherlock android-actionbar android-fragmentactivity android-support-library

public class Intro extends SherlockFragmentActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.generic);

        final ActionBar bar = getSupportActionBar();
        bar.setTitle("test title");
        bar.setTitle("test subtitle");

最后两行无效:标题和副标题根本没有设置。操作栏仅包含徽标。奇怪的是,我没有发现任何类似的问题,所以我一定做错了。

这是布局文件generic.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >
</RelativeLayout>

有什么想法吗?

1 个答案:

答案 0 :(得分:1)

经过一个小时的挫折后,我注意到由于某种原因,我接下来几行电话:

bar.setDisplayOptions(0, ActionBar.DISPLAY_SHOW_TITLE);

午夜后不要编码...