当前位置: 动力学知识库 > 问答 > 编程问答 >

use android backAsUp with custom title bar

问题描述:

I have a custom title bar, a simple relative layout, that I set as the custom title bar of my activity. But at want the android BackAsUp icon < to show up as usual (i.e. to the left of my custom layout). How do I do that? here is my code so far.

 this.getActionBar().setDisplayShowCustomEnabled(true);

this.getActionBar().setDisplayShowTitleEnabled(false);

LayoutInflater inflator = (LayoutInflater) this

.getSystemService(Context.LAYOUT_INFLATER_SERVICE);

View v = inflator.inflate(R.layout.my_title_bar, null);

this.getActionBar().setCustomView(v);

Update:

I have tried the answer at Remove Icon but have HomeAsUp in ActionBar they don't work. So one question, is order of setting those flags matter?

网友答案:

Adding the following combo solved the problem.

getActionBar().setIcon(
               new ColorDrawable(getResources().getColor(android.R.color.transparent)));
        this.getActionBar().setDisplayShowHomeEnabled(true);
分享给朋友:
您可能感兴趣的文章:
随机阅读: