Android Question Catch event in class

Discussion in 'Android Questions' started by Troberg, Mar 6, 2015.

  1. Troberg

    Troberg Well-Known Member Licensed User

    I want to do something "user control-like". My plan is something along the lines of:

    * Create a class which will create the needed controls/views in it's Initialize, using a supplied panel as host.

    * Keep this class as self-contained as possible. This means that once it's created, the activity which created it should not have to bother with internal stuff. For example, some of the views will not fire events to the activity, they will be kept internal to the class. Another mechanism will be supplied to talk to the activity.

    Example: Say that I have a database and make a custom view for some CRUD operations on a table. This is more or less self contained, and the activity has no need to know each click, it just needs a message when a change was saved. I don't want the code that belongs in the custom view to contaminate the activity (especially if I need the custom view in several places in the app). Also, in my practical case, the view could be widely different, the activity just knows "load this class" and shouldn't have to know anything more.

    All this is fairly simple, except for one thing: How do I get the contained controls in the custom view to fire events in the class, instead of in the activity?
  2. Erel

    Erel Administrator Staff Member Licensed User

  3. Troberg

    Troberg Well-Known Member Licensed User

    Thanks, it's so nice when things just work as one hoped!

    I think you just straghtened out my last major question mark for my architecture (Well, at least until I start implementing it...).
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice