2
我想在每次切换时重新启动活动, 一个活动连接网络并上载数据。切换选项卡并重启活动
如果它成功显示数据,则不需要在选项卡更改时重新启动活动。
如果无法显示数据失败,我希望每次切换选项卡时重新启动活动,并重新连接网络进行上载。
如何实现这一目标?
我想在每次切换时重新启动活动, 一个活动连接网络并上载数据。切换选项卡并重启活动
如果它成功显示数据,则不需要在选项卡更改时重新启动活动。
如果无法显示数据失败,我希望每次切换选项卡时重新启动活动,并重新连接网络进行上载。
如何实现这一目标?
请检查该代码
productSpec = tabHost.newTabSpec("Products");
Intent productsIntent = new Intent(this, ProductActivity.class);
Bundle param = new Bundle();
param.putInt("Categories", 0); //Your id
param.putCharSequence("CategoryName", "No Category");
productsIntent.putExtras(param);
productSpec.setContent(productsIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP));
//这是我们都清楚当前选项卡..
访问tabHost在不同的活动,做同样的..
Intent productsIntent = new Intent(context, ProductActivity.class);
Bundle param = new Bundle();
param.putInt("Categories", 1); //Your id
param.putCharSequence("CategoryName", categoryValues[position]);
productsIntent.putExtras(param);
MainTabActivity.productSpec.setContent(productsIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP));
MainTabActivity.tabHost.setCurrentTab(1);
请让我知道,如果您有任何疑问。 –