我在设置我从XML文件中填充的选项卡上的内容时遇到问题。Android:如何动态更改虚增标签内容?
我做添加标签到我的TabHost(“标签”)动态如下:
TabSpec passSpec = tabs.newTabSpec("Pass Tab");
passSpec.setIndicator("Passengers", getResources().getDrawable(R.drawable.tab_message));
passSpec.setContent(new TabHost.TabContentFactory() {
public View createTabContent(String tag) {
View layout = mInflater.inflate(R.layout.tab_content_passengers, null);
return(layout);
}
});
tabs.addTab(passSpec);
这工作得很好......什么我在使用后正在改变该选项卡上的内容的麻烦上。没有任何方法可以实现这一点,而无需使用全新布局重新填充所有选项卡?
我尝试以下,并没有任何反应:
mInflater = LayoutInflater.from(this);
View layout = mInflater.inflate(R.layout.tab_content_passengers, null);
TextView t = (TextView) layout.findViewById(R.id.testText);
t.setText("Hello world??");
太棒了,谢谢,我知道这只是一个愚蠢的范围问题 – TomBomb