Android的标签按钮:柄敲击/点击事件 [英] Android Tab Button: handle tap/click event

查看:193
本文介绍了Android的标签按钮:柄敲击/点击事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请参见后续code片段:

Please see the follow code fragment:

// Create an Intent to launch an Activity for the tab (to be reused)
intent = new Intent().setClass(this, HomeTabActivity.class);

// Initialize a TabSpec for each tab and add it to the TabHost
spec = tabHost.newTabSpec("home").setIndicator("Home", 
               res.getDrawable(R.drawable.ic_tab_home)).setContent(intent);
tabHost.addTab(spec);

现在,当我点击一个标签按钮,它显示了相应的活动,但后来我再次单击该按钮,我想也检测到这种点击,即使标签实际上是当前或主动标签,反正是有去做这个?我没有找到规范任何一组监听器方法。

Now when I click on an tab button, it shows corresponding activity, but then I click the button again, I want to also detect this click, even if the tab is actually the "current" or active tab, is there anyway to do this? I did not find any set listener method in spec.

推荐答案

好吧,我不认为这有什么,做,作为标签控件的一部分。有一对夫妇的事情,你可以尝试虽然。

Well, I don't think there is anything that does that as part of the tab control. There are a couple of things you could try though.


  1. 覆盖上HomeTabActivity的onNewIntent方法,看看他们每个选项卡被点击时发出的意图,但我对此表示怀疑。

  2. 您可以尝试把一个监听器上的的 getCurrentTabView 上TabHost方法

  1. Override the onNewIntent method on the HomeTabActivity and see if they send the intent every time that the tab is tapped, though I doubt it.
  2. You could try putting a listener on the view returned by the getCurrentTabView method on TabHost

这篇关于Android的标签按钮:柄敲击/点击事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆