我需要创建具有三个选项卡的应用程序。第一个选项卡是 MapViewActivity,第二个选项卡是搜索。
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_tab);
tabHost = getTabHost();
resources = getResources();
AddTab(resources.getString(R.string.tab_tag1),
R.drawable.icon_tab1, MapViewActivity.class);
AddTab(resources.getString(R.string.tab_tag2),
R.drawable.icon_tab2, MapViewActivity.class);
AddTab(resources.getString(R.string.tab_tag3), R.drawable.icon_tab3,
MapViewActivity.class);
}
private void AddTab(String tabName, int idPhoto, Class className) {
TabSpec tabspec = tabHost.newTabSpec(tabName);
tabspec.setIndicator(tabName, getResources().getDrawable(idPhoto));
Intent intent = new Intent(this, className);
tabspec.setContent(intent);
tabHost.addTab(tabspec);
}
但是当有人选择第二个标签(搜索)时,我想在第一个标签内容中显示弹出窗口。是否可以?你有一些例子吗?