我在从 XML 文件膨胀的选项卡上设置内容时遇到问题。
我通过执行以下操作将选项卡动态添加到我的 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??");