trailman
Aspiring developer
Profile
Posts: 280
Reg: Dec 10, 2010
Sedona, az
6,550
11/10/12 05:29 PM (13 years ago)

Eclipse Android Back Button Missing

Tried this (from MgoBlue) to get the back button in the nav bar: Simple solution. In the BT_screen_customURL.java file, uncomment the following code. The Android hardware back button will work like a browser back button. Works perfectly. /* Hardware Back-Key, uncomment as needed. Uncomment this to make the hardware back-key act like a browser back button Warning: If you do this the user will need to go "back" the number of times they when "forward" to return to the previous screen. */ @Override public boolean onKeyDown(int keyCode, KeyEvent event){ if ((keyCode == KeyEvent.KEYCODE_BACK) && webView.canGoBack()){ webView.goBack(); return true; } //not the back-key.. return super.onKeyDown(keyCode, event); } But I have 2 errors on line 308 and 309 so I can't even launch the app in the simulator at this point. Seemed easy enough... I assume uncommenting meant move the */ to before @Override. Is that correct?
 
David @ buzztouch
buzztouch Evangelist
Profile
Posts: 6866
Reg: Jan 01, 2010
Monterey, CA
78,840
like
11/11/12 01:48 AM (13 years ago)
I uncommented these out too and got two errors until I imported the android.view.KeyEvent file with all the other imports at the top of the screen. Add this with all the other imports at the top: import android.view.KeyEvent; This is usually easy to figure out by hovering over the red-lines under the error in the code. When I do this it shows me the error then allows me to "import" missing android files. The idea is that the KeyEvent logic isn't included in files unless it's needed. With the comments it wasn't needed. Uncommenting it made them needed :-)
 
chris1
Code is Art
Profile
Posts: 3862
Reg: Aug 10, 2012
Austin, TX
50,120
like
11/17/12 09:14 AM (13 years ago)
Just came across this post - and just in time. I was getting some negative feedback about this very issue. Thank you for helping me resolve it - and so easy!
 

Login + Screen Name Required to Post

pointerLogin to participate so you can start earning points. Once you're logged in (and have a screen name entered in your profile), you can subscribe to topics, follow users, and start learning how to make apps like the pros.