latest posts

Monodroid gave me headaches this afternoon, trying to mimic the Pivots on Windows Phone 7 on Android using the TabActivity. You would think you access an Activity after attaching it to a TabActivity. Well the answer is you can, but figuring it out on Monodroid will make your hair go gray. After digging through the Java based Android Documentation I finally figured it out. I don't know if this is the right way, but it works: Declare an enumeration object with each of your tabs: [csharp] public enum TABS { BasicInformation = 0, Detailinformation = 1, OptionalInforation = 2 }; [/csharp] Then add an abstract class to each of your Activity Objects: [csharp] public abstract class MyDroidActivity : Activity { public abstract bool SaveActivity(); // Any other custom code you had } Then inside your inherited Activity: public class BasicInfoActivity : MyDroidActivity { public override bool SaveActivity() { // Error handling to return false if for instance the fields weren't populated } } [/csharp] Then in your TabActivity Class: [csharp] private void SaveAllTabs() { TabHost.CurrentTab = (int)TABS.BasicInformation; BasicInformation biTab = (BasicInformation)LocalActivityManager.GetActivity(TabHost.CurrentTabTag); if (!biTab.SaveActivity()) { return; } // And continue with your other Tabs } [/csharp] Not the most elegant, but works. The inherited class and enumerations are not necessary, but helps keep things in order, especially if you have a larger application in my opinion.