Android Webview/Activity交互
有没有办法说如果选择了一项活动然后做某事?
我不知道这就是我问这个问题的原因,但与此类似:
if(myactivity.isselected(true)){
webview3.reload();}
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();}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果您使用选项卡,那么 onTabChange() 是正确的事件。并非所有选项卡都是单独的活动。甚至不一定有不同的布局。然后您可以检查所选选项卡是否是这样的活动
public void onTabChange(View v, int id) {
开关 (v.getId()) {
案例(R.id.tab1){
//这样做
休息;
}
。
tabhost 支持很多功能 另一个函数是 getTab() ,它将返回所选选项卡的 id(作为 int)。这是文档的链接 http://developer.android.com/reference/android /widget/TabHost.html
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.
您可以通过以下方式获取 tabhost 正在运行的活动:
然后调用该活动中的任何方法。 TABKEY_1 只是您在初始化 tabhost 时指定的选项卡名称。
You can get the activities that the tabhost is running, with this:
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.