`
yhz61010
  • 浏览: 564602 次
  • 来自: -
博客专栏
63c13ecc-ef01-31cf-984e-de461c7dfde8
libgdx 游戏开发
浏览量:12299
社区版块
存档分类
最新评论

Display back button on action bar and back event

阅读更多
原文地址:
https://stackoverflow.com/a/37185334

I think onSupportNavigateUp() is best and Easiest way to do so
check the code below
if you want it programmatically Add this line in onCreate() method
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
 
Note: make sure Actionbar is not null.

And Override this method
@Override
public boolean onSupportNavigateUp(){  
    finish();  
    return true;  
}

thats it
OR Non-programmatically you can add meta to the activity in manifest file as
<meta-data
        android:name="android.support.PARENT_ACTIVITY"
        android:value="MainActivity" />


Other solution:
mToolbar.setNavigationOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View view) {
        onBackPressed();
    }
});
分享到:
评论

相关推荐

    DisplayPort-Alt-Mode-on-USB-C.pdf

    It describes cable assemblies and adapters to adapt DisplayPort on USB Type-C to other video protocols. It describes the simultaneous use of USB Enhanced SuperSpeed and the DisplayPort protocol on ...

    thinkpad热键屏显fn热键On screen display

    完成带on screen display功能的hotkey,功能和联想的hotkey类似。支持ThinkPad屏幕亮度调节的显示,音量调节,大写键,麦克风,触摸板禁用开启,CPU使用率上升,Fn组合键显示,电池电量等等的显示。支持手动,自动...

    Dell-On-Screen-Display-Application,戴尔屏幕显示驱动

    Dell-On-Screen-Display-Application,戴尔屏幕显示驱动

    Event_Log_Explorer_4.3.8.zi

    + Added Custom columns - you can extract information from description and display it in event list. + Added alerts by event type. * NewAPI: Event description could be missing for some events. Fixed. *...

    searchBar与searchDisPlayController

    在iOS开发中,`searchBar` 和 `searchDisplayController` 是两种重要的组件,它们用于实现应用内的搜索功能,尤其在处理大量数据展示如`tableView`时尤为重要。`searchBar` 提供了一个用户输入搜索关键词的界面,而 ...

    170: Warning: (1681, ‘Integer display width is deprecated and will be removed in a future release.’)

    在Python的数据库操作中,尤其是当你使用pymysql库连接MySQL数据库时,可能会遇到一个警告,提示"Integer display width is deprecated and will be removed in a future release." 这个警告源于MySQL数据库的一个...

    audio_bargraph.zip_HD SDI_bargraph_bargraph display_sdi audio

    Allows to display an audio bargraph (peak meter and vu meter) of a HD-SD SDI embedded audio signal .

    VESA and Industry Standards and Guidelines for Computer Display Monitor Timing

    详细定义了各种视频格式(640x480、800x600、1280x720、1280x1024、1920x1080)的时序要求,包括时钟、行同步、场同步信号等,VESA MONITOR TIMING STANDARD。非常好的用户参考资料。

    BackToTop “返回顶部” 页面组件

    backToTop.style.display = 'block'; } else { backToTop.style.display = 'none'; } }); backToTop.addEventListener('click', function() { window.scrollTo(0, 0); }); ``` 这段代码首先获取了id为“back-...

    button自适应高度和自动换行

    在网页设计中,按钮(Button)的样式和布局是用户体验中的关键元素。"button自适应高度和自动换行"这个主题主要关注如何让按钮在不同屏幕尺寸和内容长度下保持良好的视觉效果。以下是对这个主题的详细解释: 一、...

    VESA Proposed DisplayPort (DP) Standard.pdf

    display connections include interfaces between a PC and monitor or projector, between a PC and TV, or between a device such as a DVD player and TV display. DP v1.1a was revised to correct errata ...

    《Hands-On GUI Programming with C++ and Qt5》---Author: Lee Zhi Eng .epub格式+code

    Connect to the MySQL database and display data obtained from it onto the Qt 5 GUI Incorporate the Qt 5 multimedia and networking module in your application Develop Google Map-like applications using ...

    Immersive autostereoscopic display based on curved screen and parallax barrier

    In this Letter, we present a display system based on a curved screen and parallax barrier, which provides stereo images with a horizontal field of view of 360° without wearing any eyewear, to achieve...

    DisplayPort_Alt_Mode_on_USB_C_d3.pdf

    DisplayPort_Alt_Mode_on_USB_C_d3.pdf DisplayPort_Alt_Mode_on_USB_C_d3.pdf 文件是关于 DisplayPort Alternate Mode on USB Type-C 的标准文档,下面是该文件中所包含的知识点: DisplayPort Alternate Mode ...

    Hands-On Game Development without Coding: Create 2D and 3D games.epub

    Hands-On Game Development without Coding: Create 2D and 3D games with Visual Scripting in Unity by Lucas Bertolini English | 2018 | ISBN: 1789538335 | 430 Pages | EPUB | 102 MB Develop your own games...

    Android板实现双屏显示,DisplayManager和Display的使用

    本篇文章将深入探讨如何使用Android原生的`DisplayManager`和`Display`类来实现这一功能。 首先,我们要理解`DisplayManager`和`Display`这两个核心概念。`DisplayManager`是Android提供的一个服务接口,它允许应用...

    好看的button样式CSS

    在网页设计中,按钮(Button)的样式是一个重要的组成部分,它不仅影响页面的美观,还直接关乎用户体验。本文将深入探讨如何使用CSS(层叠样式表)来创建好看且具有吸引力的button样式。 首先,CSS是网页设计中的...

    DP Alt Mode on USB Type C v1.0a d1_clean.pdf

    本文档是关于DisplayPort(DP)在USB Type-C上的替代模式(Alt Mode)标准的详细说明,文档编号为v1.0a d1。USB Type-C是近年来广泛使用的可逆式USB接口标准,而DisplayPort是一种高速、高带宽数字视频接口协议。本...

    带下滑线的button

    $('#underline-button').on('click', function() { alert('按钮被点击了!'); // 在这里执行其他功能,如数据提交、页面跳转等 }); ``` 综上所述,"带下滑线的button"是一个结合了设计美学和技术实现的UI元素...

Global site tag (gtag.js) - Google Analytics