Mine's a little strange to explain but I will try:

I've opted to use nibless in iPhone, and likewise I add controls in code on 
Android too. So I have a framework library for each OS that can 
"AddLabelAndText" which adds a label indented by x, y wide with a gap of x to a 
textbox that's z wide - I'm sure you get the idea. This framework also has 
inherited versions of views/activities as well as buttons etc to provide common 
functions.

In each device project I link to a common file - say "LoginScreen.cs". It will 
inherit from "BaseScreen", and each project will have a "BaseScreen.cs" 
inheriting from its respective view/activity in the framework above. In effect, 
this now means that all code in LoginScreen calls 2 different base frameworks 
depending on the device.

So LoginScreen has protected properties for all its labels and textboxes, 
buttons etc and are created in code. I've mapped common click events to both 
versions of the framework button classes, so LoginScreen has click events for 
the buttons that handle all the logic etc.

In reality, I do inherit from LoginScreen in each project also because some 
things just cannot be done the same way (badges for example seem to be 
impossible on Android) but 95% of the actual code is common to both.

Dino

From: [email protected] 
[mailto:[email protected]] On Behalf Of Wally McClure
Sent: Monday, January 30, 2012 8:59 AM
To: [email protected]; [email protected]
Subject: [mono-android] sharing code between mono touch and mono for android

I've been talking with Mark Bradley about sharing code between MT and MfA 
projects.  I'm curious what are the strategies that you are using to share code 
between the two platforms.  Any thoughts/advice are appreciated.  We've each 
got a way that we're doing.  I'm using separate projects and am linking files.  
Mark is doing something a little different where he references the .dll 
directly in his MT and MfA projects.  I think both have pluses/minuses.  What 
are you doing?  Is there some macdaddy project type that we have missed that 
would allow us to share things easily?  Are we both missing something?

Wally
_______________________________________________
Monodroid mailing list
[email protected]

UNSUBSCRIBE INFORMATION:
http://lists.ximian.com/mailman/listinfo/monodroid

Reply via email to