Method gets call on onBackPress in android -
i working on base adapter in android , want know overriden method gets call in baseadapter class if press onbackpress in activity. please me, have searched , didnt find solution.
you have listview , have custom adapter set listview. listview in activity.
class myactivity extends activity { @override public void oncreate(bundle savedinstancestate) { setcontentview(r.layout.main); listview lv= (listview) findviewbyid(r.id.listview); customadapter cus= new customadapter(myactivity.this); lv.setadapter(cus); } } class customadapter extends baseadapter { .................... }
so when press button current activity popped form stack, destroyed , previous activity in stack takes focus.this default behaviour.
http://developer.android.com/guide/components/tasks-and-back-stack.html
you can override onkeydown(params) in activity
@override public boolean onkeydown(int keycode, keyevent event) { if (keycode == keyevent.keycode_back) { onbackpressed(); } return super.onkeydown(keycode, event); } public void onbackpressed() { //do finish(); return; }
Comments
Post a Comment