What is the best approach for creating a reusable view with a custom layout in Titanium?
I would like to create a custom view t开发者_开发问答hat will allow for "pluggable" layout routines. Ideally, I like to setup the view so that when a child view is added it is automatically sized relative to the parent and other siblings.
What is the correct way to do this in Titanium? Not being a "true" Object Oriented language, overriding the "add()" method sounds like a bad idea. Is there some kind of "layout" event I can register for? Am I thinking about this the wrong way? Any suggestions are welcome!
I'm not sure if it'll do what you're looking for, but to achieve reusable OO style functionality with Appcelerator I've used the Helium library written by Kevin Whinnery of Appcelerator. It allows you to write factory functions, essentially constructors, where things you'd like to automate, like resizing to a parent view, can be encapsulated for re-use. You can make use of the configuration object passed to the constructor to alter the layout you give to your constructed view, thus making it pluggable.
精彩评论