Finishing of an activity
I have two types of views namely, Text View and Grid View, in an activity. When i'm in Grid View and if i press 'back' button i have to get the focus in text view and continue the functions so that i can again access grid view. Again if i press 'back ' button when i'm in text view i need to finish my activity. I'm able to do this when i give .setOnKeyListener() to my gridview. But the focus in grid view is lost when this is done. So, how is it possible to exit from grid view and be in text view? 开发者_如何学Python
Strange requirements. I don't know if I understand you but I try to help.
Paste it into Activity:
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if((keyCode == KeyEvent.KEYCODE_BACK)) {
Log.d(TAG, "back button pressed");
//here manage yours focus on/off and finishing activity
}
return super.onKeyDown(keyCode, event);
}
精彩评论