Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

Reusable Views

Is it possible to use the same view multiple times? Kind of like you would in HTML and CSS?

For example I have a scroll view with many views in it and in each of those views I would like the reuse a view so I don't have to write it over and over.


— asked August 14th 2010 by Chris Schultz
  • android
  • views

1 Answer

  • Accepted Answer

    To avoid writing a lot of code you could make something more abstract for the view.

    function view_to_use() {
    var view = Titanium.UI.createView({
    return view;

    then in your code to do something like

    the_element_to keep_the_view.add( view_to_use() );

    You can go lot further than this.

    — answered August 14th 2010 by Dan Tamas
The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.