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

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -