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.
- 覆盖上HomeTabActivity的onNewIntent方法,看看他们每个选项卡被点击时发出的意图,但我对此表示怀疑。
- 您可以尝试把一个监听器上的的 getCurrentTabView 上TabHost方法
- 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.
- You could try putting a listener on the view returned by the getCurrentTabView method on TabHost