2

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

sgarman
  • 6,152
  • 5
  • 40
  • 44
  • The HOME button on my HTC Desire (running Android v2.2) is a physical button - you're not going to be able to find it's location with code. – Squonk Apr 19 '13 at 22:16

2 Answers2

3

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

getWindow().getDecorView().findViewById(android.R.id.home)
Jake Wharton
  • 75,598
  • 23
  • 223
  • 230
  • Thanks! Basically I want to pass it as a view to this guy https://github.com/Espiandev/ShowcaseView. Users who beta tested my app were not familier with android paradigms. I'm assuming they were on older devices so with ABS backport they have not been "educated" yet. – sgarman Apr 19 '13 at 23:51
-1

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

Community
  • 1
  • 1
MGA
  • 7,575
  • 1
  • 14
  • 10