Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/187.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 在FadingActionBarHelper中使用setDisplayHomeAsUpEnabled时出错_Android - Fatal编程技术网

Android 在FadingActionBarHelper中使用setDisplayHomeAsUpEnabled时出错

Android 在FadingActionBarHelper中使用setDisplayHomeAsUpEnabled时出错,android,Android,我想在我的应用程序中实现FadingActionBar,以获得像最新的Google play音乐应用程序那样的效果。 下面是我如何使用FadingActionBar @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); FadingActionBarHelper helper = new FadingAct

我想在我的应用程序中实现FadingActionBar,以获得像最新的Google play音乐应用程序那样的效果。 下面是我如何使用FadingActionBar

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

        FadingActionBarHelper helper = new FadingActionBarHelper()
            .actionBarBackground(R.drawable.ab_background)
            .headerLayout(R.layout.header)
            .contentLayout(R.layout.activity_listview);
        setContentView(helper.createView(this));
        helper.initActionBar(this);
在这里,我想使用setDisplayHomeAsupabledTrue在actionBar中添加back按钮; 我在添加上面的代码时出错,说明找不到这样的方法

我的问题是,有没有办法将setDisplayHome添加为PenabledTrue;
如果没有,我们如何为FadingActionBar添加back按钮我也遇到了同样的问题,但这是因为我使用的是appcompat v7,所以您只需添加这个

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

        FadingActionBarHelper helper = new FadingActionBarHelper()
            .actionBarBackground(R.drawable.ab_background)
            .headerLayout(R.layout.header)
            .contentLayout(R.layout.activity_listview);
        setContentView(helper.createView(this));
        helper.initActionBar(this);
 getSupportActionBar().setDisplayHomeAsUpEnabled(true);

希望对您有所帮助

您可以将此方法添加到