Resources | developer.brewmp.com Resources | developer.brewmp.com

Developer

resources

List container widget and list widget differences

List widget

The list widget uses one widget to draw each list item. Each time a draw occurs, it takes this widget and, in turn, initializes it with the data for each list item and then draws each list item on the screen.

  1. The list widget can generally only draw homogeneous lists. There are some exceptions to this however, it is possible to have items with different sizes and even different colors but the list widget requires that the same widget(s) be used to draw each item. Using variable height items can at times be expensive, in longer lists, because at draw time the list widget requests the size of each item (the list container alleviates this issue by approximating offsets in heterogeneous lists).
  2. The list widget does very little initialization on start up because it does not have to create widgets for each list item, only the widgets for one list item.
  3. On creation, the lists widget requires a fully populated data model. An application can provide a special model that provides data on demand.
  4. If it is costly to initialize a list item's widgets with their data, then the list widget will not perform as well.
  5. Because there is only one widget it is difficult to provide animations in more than one of the list items at the same time. For example, it would be difficult to marquee text in multiple visible list items.
  6. Touchable items such as buttons or text widgets cannot be used in a list widget.

The list widget only performs well as long as the cost of initializing is low and the content is both static and homogeneous.

List container widget

The list container widget creates individual widgets for each visible list item, plus some extra items on each end of the list to improve livescroll performance.

  1. The list container widget supports both homogenous and heterogeneous lists. List items can vary in size and can be different types of widgets.
  2. The list container widget caches list items so that list items can be reused (based on type not data).
  3. The list container widget can have a slightly slower startup time than the list widget because it has to create more widgets.
  4. The list container widget uses more memory than the list widget because it creates widgets for each visible item and also holds some widgets in its cache.
  5. The list container widget is more flexible than the list widget when support for a heterogenous list is required.
  6. The list container performs better than the list widget when the cost of initialising a widget with its data is expensive.
  7. The list container widget supports a special type of model (ListContainerModel) that can provide data on demand, this is useful for long lists where it is expensive to read all the data up front.
  8. The list container widget supports touchable items (buttons, checkboxes, etc.).
  9. An application can set up a listener for a widget in a list container item. This is more difficult with a list widget, because the application must determine which widget was touched.
  10. The list container widget supports the use of placeholders, which can improve the performance of quick flicks when the drawing of a list item is expensive.

    Developers can provide an additional image (the placeholder) that is used during a flick. Displaying smaller images may improve performance.