https://bugzilla.novell.com/show_bug.cgi?id=679789
https://bugzilla.novell.com/show_bug.cgi?id=679789#c1 Jonathan Pryor <[email protected]> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |CLOSED CC| |[email protected] Resolution| |INVALID --- Comment #1 from Jonathan Pryor <[email protected]> 2011-03-16 15:00:18 UTC --- My guess is that you changed the code between then and now. There are two ways (at least) to make this work. Way 1: Don't inherit from Android.App.Activity, but instead Android.App.TabActivity, as discussed in the TabActivity tutorial: http://mono-android.net/Tutorials/Hello_Views/Tab_Layout Then, DO NOT create a new TabHost instance (as you did), but instead use the TabActivity.TabHost property: // within a TabActivity subclass... protected override void OnCreate (Bundle bundle) { base.OnCreate(bundle); SetContentView(Resource.Layout.Main); TabHost.TabSpec spec; // Resusable TabSpec for each tab Intent intent; // Reusable Intent for each tab // Create an Intent to launch an Activity for the tab intent = new Intent(this, typeof(MyHelloView)); intent.AddFlags(ActivityFlags.NewTask); // Initialize a TabSpec for each tab and add it to the TabHost spec = TabHost.NewTabSpec("MyHelloView"); spec.SetIndicator("Hello", Resources.GetDrawable(Resource.Drawable.Icon)); spec.SetContent(intent); TabHost.AddTab(spec); } Way 2: Inherit from ActivityGroup, lookup the TabHost instance using FindViewById(), and Setup the TabHost instance, as is required by the documentation: http://developer.android.com/reference/android/widget/TabHost.html#setup(android.app.LocalActivityManager) You'll want to inherit from ActivityGroup so you have access to the LocalActivityManager property: [Activity (Label = "TabHost Bug?", MainLauncher = true)] public class Activity1 : ActivityGroup { protected override void OnCreate (Bundle bundle) { base.OnCreate(bundle); SetContentView(Resource.Layout.Main); TabHost TabHost = FindViewById<TabHost>(Android.Resource.Id.TabHost); TabHost.Setup(LocalActivityManager); TabHost.TabSpec spec; // Resusable TabSpec for each tab Intent intent; // Reusable Intent for each tab // Create an Intent to launch an Activity for the tab intent = new Intent(this, typeof(MyHelloView)); intent.AddFlags(ActivityFlags.NewTask); // Initialize a TabSpec for each tab and add it to the TabHost spec = TabHost.NewTabSpec("MyHelloView"); spec.SetIndicator("Hello", Resources.GetDrawable(Resource.Drawable.Icon)); spec.SetContent(intent); TabHost.AddTab(spec); } } Either of these mechanisms work for me, though inheriting from TabActivity seems to be the easier way. -- Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are the QA contact for the bug. _______________________________________________ mono-bugs maillist - [email protected] http://lists.ximian.com/mailman/listinfo/mono-bugs
