简体   繁体   English

android:单击操作栏中的主页徽标时的自定义操作

[英]android : customized action when home logo in action bar si clicked

i changed the logo to an action icon and i want to perform an action when the logo is clicked. 我将徽标更改为操作图标,并且单击徽标后要执行操作。

How can i customize the action when the home logo in action bar is clicked? 单击操作栏中的主页徽标时,如何自定义操作?

thank you 谢谢

In onOptionsItemSelected() of your activity, watch for an ID of android.R.id.home -- that will be when the home icon/logo is pressed. 在活动的onOptionsItemSelected()中,注意ID为android.R.id.home ,即当按下主页图标/徽标时。 You can then perform whatever action makes sense (eg, move to your app's main screen). 然后,您可以执行任何有意义的操作(例如,移至应用程序的主屏幕)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM