Search code examples
androiduser-interfacemvpxamarin.androidui-patterns

Using the MVP pattern with MonoDroid


Here's my attempt at using MVP (or Passive View more specifically?) with a MonoDroid app:

https://gist.github.com/857356

My main goal isn't reuse, but rather increased testability and (hopefully) improved maintainability. Reuse would be a nice side-effect, but I currently don't plan to do a MonoTouch version or anything.

I'm generally pretty happy with it (with one exception), but I definitely need some critique/evaluation.

The one exception: the method "GetPortfolioIdForContextMenu" returns an 'int', which doesn't feel quite right, given the rest of the methods don't have to do that. It just feels wrong, but I can't quite put my finger on 'why', or what to even do about it.


Solution

  • onCreateContextMenu contains the View for which context menu is to be created. You can set the portfolio id as tag for each view and then use it in the onCreateContextMenu. HTH !