其他分享
首页 > 其他分享> > android-导航抽屉图标在操作栏中设置CustomView时消失

android-导航抽屉图标在操作栏中设置CustomView时消失

作者:互联网

为什么导航抽屉图标在设置customView by时消失了

actionbar.setCustomView(R.layout.blah);

如何解决?

解决方法:

好的,您没有发布任何代码,因此我必须在这里假设.因此,如果您可以更新问题并显示实际代码!

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    ActionBar actionBar = getActionBar();

    // Depending on what your custom Action Bar will do, you might want to disable these!
    actionBar.setDisplayShowHomeEnabled(false);
    actionBar.setDisplayShowTitleEnabled(false);

    LayoutInflater inflater = LayoutInflater.from(this);

    View customView = inflater.inflate(R.layout.custom_actionbar, null);

    // Here is how you can get specific items from your custom view!
    TextView titleTextView = (TextView) customView.findViewById(R.id.title_text);
    titleTextView.setText("My Own Title");

    ...

    // MAKE SURE THESE ARE SET!! BOTH OF THEM!!
    actionBar.setCustomView(mCustomView);
    actionBar.setDisplayShowCustomEnabled(true);
}

最大的问题可能是最后的代码.请确保您具有该代码!

标签:navigation-drawer,android-actionbar-compat,android
来源: https://codeday.me/bug/20191029/1958815.html