在操作栏上显示后退按钮 [英] Display back button on action bar
本文介绍了在操作栏上显示后退按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图在 Action bar
上显示一个 Back button
以移动上一页/活动或到主页(第一次打开).而我做不到.
I'm trying to display a Back button
on the Action bar
to move previous page/activity or to the main page (first opening).
And I can not do it.
我的代码.
ActionBar actionBar = getActionBar();
actionBar.setHomeButtonEnabled(true);
代码在onCreate
中.
推荐答案
嗯,这是一个简单的显示返回按钮
well this is simple one to show back button
actionBar.setDisplayHomeAsUpEnabled(true);
然后你可以在 onOptionsItemSelected 自定义返回事件
and then you can custom the back event at onOptionsItemSelected
case android.R.id.home:
this.finish();
return true;
这篇关于在操作栏上显示后退按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文