带后退箭头的操作栏 [英] Action bar with back arrow

查看:120
本文介绍了带后退箭头的操作栏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在制作一个应用,我想在片段中放置一个带有后退箭头的操作栏.
因此,我已经有了带有操作栏的片段,但是不知道如何在其上放置后退箭头.你能帮我吗?
谢谢
吉列尔梅
这是带有操作栏标签的片段

I am making an app and I want to put an action bar with a back arrow in a fragment.
So, I already have the fragment with the action bar but don't know how to put the back arrow on it. Can you help me please?
Thank you,
Guilherme
This is the fragment with an action bar tag

推荐答案

如果要显示片段中的后退按钮,请在片段中添加以下行:(((AppCompatActivity)getActivity()).getSupportActionBar().setDisplayHomeAsUpEnabled(true);

Add following line in your fragment if you want to show the back button from the fragment : ((AppCompatActivity)getActivity()).getSupportActionBar().setDisplayHomeAsUpEnabled(true);

这样做会更好.您将活动的父级添加到清单文件中,以确保按下向后箭头时可以打开父级活动.

It would be better that along with doing this. You add the parent of the activity in the manifest file to make sure that parent activity is opened when back arrow is pressed.

这篇关于带后退箭头的操作栏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆