开发者

Android on TabHost little more depth of the problem, there is the hard return key on the treatment

开发者 https://www.devze.com 2023-01-03 20:02 出处:网络
I have a question on the Android Activity, for example I have a TabHost, and there are included four Activities, the first tab is a search Activity, enter a keyword in the current result of this Activ

I have a question on the Android Activity, for example I have a TabHost, and there are included four Activities, the first tab is a search Activity, enter a keyword in the current result of this Activity to return, and in the current Activity display. Is called to display the search results themselves. And after searching several times, and then return to key mobile phone keypad, the display is the result of the last search keyword, I want the press back key to return to the last call of the Activity or TabHost. Should I do?

By the way, in a tab in the use of Intent calls a Activity,

eg: host.addTab (host.newTabSpec ("friend"). setIndicator ("search") . SetContent (new Intent (this, Search.class)));

In this Activity in the need to call another Activity,

e.开发者_StackOverflow社区g: startActivity (new Intent (this, Other.class));

Also called another Activity displayed on this tab, but not yet jump out of the show. I ask how you can achieve this?


First, you can use startActivityForResult(...) instead of startActivity(...). This means that when you're done with the activity, you want to come back to the activity that started it so you can do more.

Second, you can override the onKeyDown(...) method and define whatever behavior you want for the back key. however, this is not recommended by Google except when absolutely necessary.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号