You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@pivot.apache.org by Brendan cheng <cc...@hotmail.com> on 2011/09/18 07:34:23 UTC

Using BXML for ListView ItemRender

Hi,

I'm trying to load a list of item into a scroll pane of my main window where each item is a instance of commentItemRendererI created a bxml file for this commentItemRenderer called  comment_pane.bxml.
The problem is I couldn't have the list shown in the main window.
What's wrong?
Brendan
public class CommentItemRenderer extends BoxPane implements
		ListView.ItemRenderer, Bindable {
	@BXML private Label dateLabel = null;

	public CommentItemRenderer() {
		super(Orientation.VERTICAL);
	}

	@Override
	public void initialize(Map<String, Object> namespace, URL location,
			Resources resources) {
	}

	@Override
	public void render(Object item, int index, ListView listView,
			boolean selected, boolean checked, boolean highlighted,
			boolean disabled) {
		dateLabel.setText((String) item);
	}

	@Override
	public String toString(Object item) {
		return null;
	}
}
my bxml file: comment_pane.bxml
<thumbnail:CommentItemRenderer
    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" text="2011-09-19 08:34"/>
        				<Label bxml:id="authorLabel" text="Mr. David Foo"/>
        				<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" text="@sample1.txt"/>
    			</BoxPane>
            </Border>
		</TablePane.Row>
		
    </TablePane>
    </BoxPane>
</thumbnail:CommentItemRenderer>
I load it into my main window from its BXML file here:
<ScrollPane bxml:id="rightScrollPane"><ListView bxml:id="listView">
<itemRenderer>
<bxml:include src="thumbnail/comment_pane.bxml"/>
</itemRenderer>
</ListView>
</ScrollPane>
 		 	   		  

Re: Using BXML for ListView ItemRender

Posted by Bill van Melle <bi...@gmail.com>.
You may need to call validate().  I ran into this just today.  See my
post at http://apache-pivot-users.399431.n3.nabble.com/Difficulties-implementing-a-ListView-ItemRenderer-td3498527.html

RE: Using BXML for ListView ItemRender

Posted by Brendan cheng <cc...@hotmail.com>.
Hi Greg,
Here is the complete program which the itemRender from both Accordion can't be shown.
Thanks in advance!

----------------------------------------
> Subject: Re: Using BXML for ListView ItemRender
> From: gk_brown@verizon.net
> Date: Mon, 19 Sep 2011 08:50:05 -0400
> To: user@pivot.apache.org
>
> Hard to say. Can you provide a complete runnable example that demonstrates the problem?
>
> On Sep 19, 2011, at 8:38 AM, Brendan cheng wrote:
>
> >
> > I tried to insert 2 items but the list view only show 2 blanks column where I can highlight but no content shown.How come?
> > here is my code of loading the items into it:
> > @Override
> > public void initialize(Map<String, Object> namespace, URL location,
> > Resources resources) {
> > List<String> liststring = new ArrayList<String>();
> > liststring.add("Abc");
> > liststring.add("ccb");
> > listView.setListData(liststring);
> >
> > ----------------------------------------
> >> Subject: Re: Using BXML for ListView ItemRender
> >> From: gk_brown@verizon.net
> >> Date: Mon, 19 Sep 2011 07:58:45 -0400
> >> To: user@pivot.apache.org
> >>
> >> Overall, that looks OK, though I think you'll want to set the "horizontalScrollBarPolicy" attribute to "fill" on your ScrollPane. You may also want to set the "variableItemHeight" style of the ListView to true since your renderer's row height is set to -1 (meaning "use default height"). If you don't set this style, the list view will assume a fixed row height.
> >> G
> >>
> >>
> >> On Sep 18, 2011, at 1:34 AM, Brendan cheng wrote:
> >>
> >>>
> >>> Hi,
> >>>
> >>> I'm trying to load a list of item into a scroll pane of my main window where each item is a instance of commentItemRendererI created a bxml file for this commentItemRenderer called comment_pane.bxml.
> >>> The problem is I couldn't have the list shown in the main window.
> >>> What's wrong?
> >>> Brendan
> >>> public class CommentItemRenderer extends BoxPane implements
> >>> ListView.ItemRenderer, Bindable {
> >>> @BXML private Label dateLabel = null;
> >>>
> >>> public CommentItemRenderer() {
> >>> super(Orientation.VERTICAL);
> >>> }
> >>>
> >>> @Override
> >>> public void initialize(Map<String, Object> namespace, URL location,
> >>> Resources resources) {
> >>> }
> >>>
> >>> @Override
> >>> public void render(Object item, int index, ListView listView,
> >>> boolean selected, boolean checked, boolean highlighted,
> >>> boolean disabled) {
> >>> dateLabel.setText((String) item);
> >>> }
> >>>
> >>> @Override
> >>> public String toString(Object item) {
> >>> return null;
> >>> }
> >>> }
> >>> my bxml file: comment_pane.bxml
> >>> <thumbnail:CommentItemRenderer
> >>> 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" text="2011-09-19 08:34"/>
> >>> <Label bxml:id="authorLabel" text="Mr. David Foo"/>
> >>> <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" text="@sample1.txt"/>
> >>> </BoxPane>
> >>> </Border>
> >>> </TablePane.Row>
> >>>
> >>> </TablePane>
> >>> </BoxPane>
> >>> </thumbnail:CommentItemRenderer>
> >>> I load it into my main window from its BXML file here:
> >>> <ScrollPane bxml:id="rightScrollPane"><ListView bxml:id="listView">
> >>> <itemRenderer>
> >>> <bxml:include src="thumbnail/comment_pane.bxml"/>
> >>> </itemRenderer>
> >>> </ListView>
> >>> </ScrollPane>
> >>>
> >>
> >
>
 		 	   		  

Re: Using BXML for ListView ItemRender

Posted by Greg Brown <gk...@verizon.net>.
Hard to say. Can you provide a complete runnable example that demonstrates the problem?

On Sep 19, 2011, at 8:38 AM, Brendan cheng wrote:

> 
> I tried to insert 2 items but the list view only show 2 blanks column where I can highlight but no content shown.How come? 
> here is my code of loading the items into it:
> 	@Override
> 	public void initialize(Map<String, Object> namespace, URL location,
> 			Resources resources) {
> 		List<String> liststring = new ArrayList<String>();
> 		liststring.add("Abc");
> 		liststring.add("ccb");
> 		listView.setListData(liststring); 
> 
> ----------------------------------------
>> Subject: Re: Using BXML for ListView ItemRender
>> From: gk_brown@verizon.net
>> Date: Mon, 19 Sep 2011 07:58:45 -0400
>> To: user@pivot.apache.org
>> 
>> Overall, that looks OK, though I think you'll want to set the "horizontalScrollBarPolicy" attribute to "fill" on your ScrollPane. You may also want to set the "variableItemHeight" style of the ListView to true since your renderer's row height is set to -1 (meaning "use default height"). If you don't set this style, the list view will assume a fixed row height.
>> G
>> 
>> 
>> On Sep 18, 2011, at 1:34 AM, Brendan cheng wrote:
>> 
>>> 
>>> Hi,
>>> 
>>> I'm trying to load a list of item into a scroll pane of my main window where each item is a instance of commentItemRendererI created a bxml file for this commentItemRenderer called comment_pane.bxml.
>>> The problem is I couldn't have the list shown in the main window.
>>> What's wrong?
>>> Brendan
>>> public class CommentItemRenderer extends BoxPane implements
>>> ListView.ItemRenderer, Bindable {
>>> @BXML private Label dateLabel = null;
>>> 
>>> public CommentItemRenderer() {
>>> super(Orientation.VERTICAL);
>>> }
>>> 
>>> @Override
>>> public void initialize(Map<String, Object> namespace, URL location,
>>> Resources resources) {
>>> }
>>> 
>>> @Override
>>> public void render(Object item, int index, ListView listView,
>>> boolean selected, boolean checked, boolean highlighted,
>>> boolean disabled) {
>>> dateLabel.setText((String) item);
>>> }
>>> 
>>> @Override
>>> public String toString(Object item) {
>>> return null;
>>> }
>>> }
>>> my bxml file: comment_pane.bxml
>>> <thumbnail:CommentItemRenderer
>>> 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" text="2011-09-19 08:34"/>
>>> <Label bxml:id="authorLabel" text="Mr. David Foo"/>
>>> <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" text="@sample1.txt"/>
>>> </BoxPane>
>>> </Border>
>>> </TablePane.Row>
>>> 
>>> </TablePane>
>>> </BoxPane>
>>> </thumbnail:CommentItemRenderer>
>>> I load it into my main window from its BXML file here:
>>> <ScrollPane bxml:id="rightScrollPane"><ListView bxml:id="listView">
>>> <itemRenderer>
>>> <bxml:include src="thumbnail/comment_pane.bxml"/>
>>> </itemRenderer>
>>> </ListView>
>>> </ScrollPane>
>>> 
>> 
> 		 	   		  


RE: Using BXML for ListView ItemRender

Posted by Brendan cheng <cc...@hotmail.com>.
I tried to insert 2 items but the list view only show 2 blanks column where I can highlight but no content shown.How come? 
here is my code of loading the items into it:
	@Override
	public void initialize(Map<String, Object> namespace, URL location,
			Resources resources) {
		List<String> liststring = new ArrayList<String>();
		liststring.add("Abc");
		liststring.add("ccb");
		listView.setListData(liststring); 

----------------------------------------
> Subject: Re: Using BXML for ListView ItemRender
> From: gk_brown@verizon.net
> Date: Mon, 19 Sep 2011 07:58:45 -0400
> To: user@pivot.apache.org
>
> Overall, that looks OK, though I think you'll want to set the "horizontalScrollBarPolicy" attribute to "fill" on your ScrollPane. You may also want to set the "variableItemHeight" style of the ListView to true since your renderer's row height is set to -1 (meaning "use default height"). If you don't set this style, the list view will assume a fixed row height.
> G
>
>
> On Sep 18, 2011, at 1:34 AM, Brendan cheng wrote:
>
> >
> > Hi,
> >
> > I'm trying to load a list of item into a scroll pane of my main window where each item is a instance of commentItemRendererI created a bxml file for this commentItemRenderer called comment_pane.bxml.
> > The problem is I couldn't have the list shown in the main window.
> > What's wrong?
> > Brendan
> > public class CommentItemRenderer extends BoxPane implements
> > ListView.ItemRenderer, Bindable {
> > @BXML private Label dateLabel = null;
> >
> > public CommentItemRenderer() {
> > super(Orientation.VERTICAL);
> > }
> >
> > @Override
> > public void initialize(Map<String, Object> namespace, URL location,
> > Resources resources) {
> > }
> >
> > @Override
> > public void render(Object item, int index, ListView listView,
> > boolean selected, boolean checked, boolean highlighted,
> > boolean disabled) {
> > dateLabel.setText((String) item);
> > }
> >
> > @Override
> > public String toString(Object item) {
> > return null;
> > }
> > }
> > my bxml file: comment_pane.bxml
> > <thumbnail:CommentItemRenderer
> > 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" text="2011-09-19 08:34"/>
> > <Label bxml:id="authorLabel" text="Mr. David Foo"/>
> > <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" text="@sample1.txt"/>
> > </BoxPane>
> > </Border>
> > </TablePane.Row>
> >
> > </TablePane>
> > </BoxPane>
> > </thumbnail:CommentItemRenderer>
> > I load it into my main window from its BXML file here:
> > <ScrollPane bxml:id="rightScrollPane"><ListView bxml:id="listView">
> > <itemRenderer>
> > <bxml:include src="thumbnail/comment_pane.bxml"/>
> > </itemRenderer>
> > </ListView>
> > </ScrollPane>
> >
>
 		 	   		  

Re: Using BXML for ListView ItemRender

Posted by Greg Brown <gk...@verizon.net>.
Overall, that looks OK, though I think you'll want to set the "horizontalScrollBarPolicy" attribute to "fill" on your ScrollPane. You may also want to set the "variableItemHeight" style of the ListView to true since your renderer's row height is set to -1 (meaning "use default height"). If you don't set this style, the list view will assume a fixed row height.
G


On Sep 18, 2011, at 1:34 AM, Brendan cheng wrote:

> 
> Hi,
> 
> I'm trying to load a list of item into a scroll pane of my main window where each item is a instance of commentItemRendererI created a bxml file for this commentItemRenderer called  comment_pane.bxml.
> The problem is I couldn't have the list shown in the main window.
> What's wrong?
> Brendan
> public class CommentItemRenderer extends BoxPane implements
> 		ListView.ItemRenderer, Bindable {
> 	@BXML private Label dateLabel = null;
> 
> 	public CommentItemRenderer() {
> 		super(Orientation.VERTICAL);
> 	}
> 
> 	@Override
> 	public void initialize(Map<String, Object> namespace, URL location,
> 			Resources resources) {
> 	}
> 
> 	@Override
> 	public void render(Object item, int index, ListView listView,
> 			boolean selected, boolean checked, boolean highlighted,
> 			boolean disabled) {
> 		dateLabel.setText((String) item);
> 	}
> 
> 	@Override
> 	public String toString(Object item) {
> 		return null;
> 	}
> }
> my bxml file: comment_pane.bxml
> <thumbnail:CommentItemRenderer
>     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" text="2011-09-19 08:34"/>
>         				<Label bxml:id="authorLabel" text="Mr. David Foo"/>
>         				<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" text="@sample1.txt"/>
>     			</BoxPane>
>             </Border>
> 		</TablePane.Row>
> 		
>     </TablePane>
>     </BoxPane>
> </thumbnail:CommentItemRenderer>
> I load it into my main window from its BXML file here:
> <ScrollPane bxml:id="rightScrollPane"><ListView bxml:id="listView">
> <itemRenderer>
> <bxml:include src="thumbnail/comment_pane.bxml"/>
> </itemRenderer>
> </ListView>
> </ScrollPane>
>