Yes, you can easily create a list item renderer whose structure is defined in BXML by using a root element that implements the ListView.ItemRenderer interface. For example, you could create a subclass of TableView called CommentItemRenderer that implements this interface. You could use @BXML annotations to get access to the dateLabel, authorLabel, and summaryLabel elements so you can set their values in the render() method.
On Sep 17, 2011, at 9:07 AM, Brendan cheng wrote: > This example show the format of ListView is created inside java code, so that > to change the style of the list may have to change the code. > But I want to make use of BXML file for the ListView, is that possible to > achieve in Pivot? > > From: [email protected] > Subject: Re: How to dynamically add component to window > Date: Sat, 17 Sep 2011 08:10:38 -0400 > To: [email protected] > > Sounds like this might be a good use case for a custom list view item > renderer. Here is an example: > > http://pivot.apache.org/tutorials/web-queries.html > > On Sep 17, 2011, at 7:58 AM, Brendan cheng wrote: > > My program need to show a series of comment displayed in a sroll pane > somewhere in my main window. > I created a bxml file called CommentPane which take three variables Date, > Author and comment. > And the list of comments stored in database. > > so my CommentPane code like this: > <thumbnail:CommentPane > xmlns:bxml="http://pivot.apache.org/bxml" > xmlns:thumbnail="hk.itags.gui.thumbnail" > xmlns="org.apache.pivot.wtk"> > <BoxPane> > <TablePane> > <columns> > <TablePane.Column width="1*"/> > </columns> > > <TablePane.Row height="-1"> > <Border styles="{color:'#999999'}"> > <TablePane> > <columns> > <TablePane.Column width="-1"/> > <TablePane.Column width="1*"/> > <TablePane.Column width="-1"/> > ; </columns> > <TablePane.Row height="-1"> > <Label bxml:id="dateLabel" /> > <Label bxml:id="authorLabel" /> > <PushButton buttonData=">" > styles="{minimumAspectRatio:1.5}"/> > </TablePane.Row> > </TablePane> > </Border> > </TablePane.Row> > > <TablePane.Row height="1*"> > <Border styles="{color:'#999999'}"> > <BoxPane styles="{padding:6, verticalAlignment:'top'}"> > <Label bxml:id="summaryLabel" text="Summary"/> > <TextArea bxml:id="descriptionTextArea" > minimumHeight="2"/> > </BoxPane> > </Border> > </TablePane.Row> > > </TablePane> > </BoxPane> > </thumbnail:CommentPane> > > if I use BXML serializer, i can load one into my scroll pane with setView. > but when I load a second one, I have an error message "ID dateLabel is > already in use". > > I can't use bxml:include in bxml file because I don't know until I read the > database. > > Hopefully, that's clear. > > Brendan > > > > > > Date: Sat, 17 Sep 2011 17:45:04 +0700 > > Subject: Re: How to dynamically add component to window > > From: [email protected] > > To: [email protected] > > > > Here is a test that shows how to use the 'inline' flag to include BXML. > > http://svn.apache.org/repos/asf/pivot/trunk/tests/src/org/apache/pivot/tests/include_test.bxml > > http://svn.apache.org/repos/asf/pivot/trunk/tests/src/org/apache/pivot/tests/include_test.content.bxml > > > > On 17 September 2011 17:42, Chris Bartlett <[email protected]> wrote: > > &g t; 2011/9/17 Brendan cheng <[email protected]>: > > >> Actually, I was trying to inject a series of box pane from the bxml > > >> files. > > > Are you talking about using BXML's 'include' functionality? > > > http://pivot.apache.org/tutorials/bxml-primer.html > > > > > > If you are, then you can include the same BXML frag ments multiple > > > times (or any fragments, including ones where the BXML IDs of > > > Components might clash) by using the inline flag > > > <bxml:include src="foo.bxml" inline="true"/> > >
