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:
public enum TABS {
     BasicInformation = 0, Detailinformation = 1, OptionalInforation = 2 }
; ]]>
Then add an abstract class to each of your Activity Objects:
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 }
}
]]>
Then in your TabActivity Class:
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 }
]]>
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.