开发者

Android Webview/Activity Interaction

Is there a way to say if an activity is selected then do something?

I dont know the statement which is why i am asking this question, but similar开发者_如何学运维 to this:

if(myactivity.isselected(true)){
webview3.reload();}


If you are using tabs, then onTabChange() is the correct event for that. Not all tabs are individual activities. Not even necessarily different layouts. Then you can check to see if the selected tab is the activity like this

public void onTabChange(View v, int id) { switch (v.getId()) { case (R.id.tab1) { //Do this break; } }

The tabhost supports alot of functionality. Another funcitonis getTab() which will return the id (as an int) of the tab selected. Heres a link to the documentation http://developer.android.com/reference/android/widget/TabHost.html


When user moves through different user interface , he/she start different activities. Since you have different tabs, you should have three different screens and so three different activities , if user is moving from one tab to another, you should first pause the initial activity and should start other activity.


You can get the activities that the tabhost is running, with this:

YourActivity act = (YourActivity) getLocalActivityManager().getActivity(TABKEY_1);

then call any method you have in that activity. TABKEY_1 is just the name for the tab that you give when you initialized the tabhost.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜