问题描述
我正在制作一些高级的TabActivity
,但是我需要获取TabHost
中的每个TabView
多数民众赞成.使用tabHost.getCurrentTabView()
我可以获取当前的TabView
,但是有没有办法通过其ID获取TabView
?
I'm making some an advanced TabActivity
but I need to get every TabView
thats in the TabHost
. With tabHost.getCurrentTabView()
I can get the current TabView
but is there a way to get a TabView
by its ID?
我设法通过在onCreate()
方法中执行for循环来解决该问题,在该方法中,我转到每个选项卡并将所有View
对象放入数组中.
I managed to make a workaround by doing a for loop in the onCreate()
method where I go to every tab and put all the View
objects in an Array.
private View[] tabs;
for(int i = 0; i < getTabWidget().getTabCount(); i++)
{
tabHost.setCurrentTab(i);
tabs[i] = tabHost.getCurrentTabView();
}
推荐答案
Android中没有TabView
.
There is no TabView
in Android.
要通过标签的ID查找标签的内容,请在TabHost
上调用findViewById()
.
To find the contents of a tab via its ID, call findViewById()
on the TabHost
.
这篇关于Android TabHost有一种通过ID获取TabView的方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!