简体   繁体   English

Android actionBar OnClick()

[英]Android actionBar OnClick()

This may be a odd question, but I want a handler to handle a click on the actionbar, This because I use a background to draw the Icon/logo combination because it doesn't fit right when I use the build in methods. 这可能是一个奇怪的问题,但是我希望处理程序能够处理操作栏上的单击,这是因为我使用背景来绘制图标/徽标组合,因为当我使用内置方法时,这种组合不合适。

This results in not having an Icon or logo which you can click to go to the home activity, which I want when you click the actionbar. 这将导致没有图标或徽标,您可以单击该图标或徽标进入家庭活动,单击操作栏时需要该图标或徽标。

I tried a lot of things, making the logo/icon invisible and other things but I can't figure out how to get it to work. 我做了很多尝试,使徽标/图标不可见等,但是我不知道如何使它工作。 Any ideas? 有任何想法吗?

The actionbar looks like this: 动作栏如下所示:

    final ActionBar actionBar = getActionBar(); 
    actionBar.setDisplayShowTitleEnabled(false);
    actionBar.setDisplayShowHomeEnabled(false);

    Bitmap bm = UnscaledBitmapLoader.loadFromResource(getResources(), R.drawable.logo, null);
    BitmapDrawable background = new BitmapDrawable(this.getResources(), bm);
    background.setTileModeX(android.graphics.Shader.TileMode.CLAMP); 
    actionBar.setBackgroundDrawable(background);

The bitmaploader doesn't do anything special which would prevent it. bitmaploader并没有做任何特殊的事情来阻止它。 How to I get a onclick listener for the actionbar? 如何获取操作栏的onclick侦听器?

How to I get a onclick listener for the actionbar? 如何获取操作栏的onclick侦听器?

That is not supported, sorry. 不支持,抱歉。

This because I use a background to draw the Icon/logo combination because it doesn't fit right when I use the build in methods. 这是因为我使用背景来绘制图标/徽标组合,因为当我使用内置方法时,它不合适。

It works for everybody else. 它适用于其他人。 Perhaps you should consider asking a different question on SO on this topic, with screenshots to illustrate your problem. 也许您应该考虑就此主题在SO上提出其他问题,并使用屏幕截图说明您的问题。

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

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