Reference android.R.id.home on pre 3.0 devices

2019-02-26 02:55发布

Is there an easy way to get a reference to the home button on devices running less then 3.0?

I can do findViewById(android.R.id.home) on 3.0 and later but that fails to work on older devices. I don't need to listen for clicks, I just need its location to position another view.

For clarification I'm referring to this view: http://developer.android.com/guide/topics/ui/actionbar.html#Home

2条回答
仙女界的扛把子
2楼-- · 2019-02-26 03:16

I don't know what you're doing... but it sounds hacky :)

getWindow().getDecorView().findViewById(android.R.id.home)
查看更多
做个烂人
3楼-- · 2019-02-26 03:35

You probably shouldn't override the default behaviour of the home button, however take a look here and see if it helps.

查看更多
登录 后发表回答