Recent Changes‎ > ‎

ListView and GridView Rendering

posted May 26, 2011, 8:40 AM by Tor Norbye   [ updated May 26, 2011, 11:17 AM ]
Up until now, ListViews have not been shown in the layout editor for a variety of reasons - one of them being that the content (and layout) of each list view item is configured via Java code in your activity rather than via XML in the layout file.

However, in ADT 11 we've improved this in a couple of ways. First, we show some default, sample data in the list such that when looking at a larger layout you can instantly see where your list is, how large it is, etc:
Second, you can choose which layout to use for each list view item. This is particularly important if you have a custom layout you want to check and edit. To configure this, right click on ListView (or ExpandableListView or GridView), and choose between one of the standard list item layouts or select "Choose Layout" to pick one of your own:
(Note that you can also "Choose Header" and "Choose Footer" to configure header and footer layouts to be shown in the tool as well).

Selecting Choose Layout will show you the Resource Chooser:
Choosing one of the laoyuts, such as list_item_session, will then show the ListView with the given list item layout (and sample data):
Note however that this is simply configuring how the ListView will be shown and edited in the tool. You will still need to go and write a ListAdapter and configure your ListView from Java code just as before.

Note: This feature depends on a new version of the "layout library" which ships with the SDK. We are working on backporting it to previous SDK versions right now, and once they are released ADT 11 will begin rendering ListViews.
Comments