我想将一些活动放在TabHost中作为标签并稍后访问它们。
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
SetContentView(Resource.Layout.FirstView);
TabHost.TabSpec spec;
sspec = TabHost.NewTabSpec ("tab1");
spec.SetIndicator ("tab1");
spec.SetContent (new Intent (this, typeof(LiveView)));
TabHost.AddTab (spec);
spec = TabHost.NewTabSpec ("tab2");
spec.SetIndicator ("tab2");
spec.SetContent (new Intent (this, typeof(DetailsView)));
TabHost.AddTab (spec);
}
public void Show(Fragment frag)
{
var activityFromTab = ... // Get activity from tab widget
}
有什么想法吗?
答案 0 :(得分:0)
我通过使用
解决了这个问题TabRootView currentRootView = (TabRootView)this.LocalActivityManager.GetActivity (currentRootTag);
我将clid的意图添加到父活动的TabHost中,并通过标记(字符串常量)标记此意图。然后使用父级的标记和LocalActivityManager属性来指定目标。