的Android如何在动作条点击标识图标? [英] Android how to make clickable logo icon in actionbar?
本文介绍了的Android如何在动作条点击标识图标?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我真的使用SherlockActionBar我的应用程序。在我的清单我定义的标志和启动图标。
I`m using SherlockActionBar for my application. In my manifest I define icon for logo and launch.
android:icon="@drawable/ic_launcher"
如何使它可以点击的,处理它`pressing事件?我希望能够要回我的仪表板由pressing的标志。
How to make it clickable and handle the event of it`s pressing? I want to be able to back to my dashboard by pressing the logo.
推荐答案
使用
actionBar.setDisplayHomeAsUpEnabled(true);
与
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
//Do stuff
return true;
default:
return super.onOptionsItemSelected(item);
}
}
这篇关于的Android如何在动作条点击标识图标?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文