java - Apache Pivot and custom ListView ItemRenderer -
say want following layout in list view's items:
<tablepane styles = "{padding : 5, horizontalspacing : 5, verticalspacing : 5}" > <columns> <tablepane.column width = "1*"/> <tablepane.column width = "21"/> </columns> <tablepane.row height="-1"> <textinput bxml:id ="txtname" textsize="15" /> <tablepane.filler/> </tablepane.row> <tablepane.row height="-1"> <tablepane.filler/> <activityindicator active="true" width="16" height="16"/> </tablepane.row> </tablepane>
and have following custom itemrenderer:
public class customlistrenderer extends tablepane implements listview.itemrenderer { // stuff here }
what best way use bxml snippet above custom listrenderer?
the way make customlistrenderer might call "code behind" similarly-named bxml file, , add factory method create calling bxml serializer. this:
public class customlistrenderer extends tablepane implements listview.itemrenderer { public static customlistrenderer create() throws ioexception, serializationexception { bxmlserializer bxmlserializer = new bxmlserializer(); return (customlistrenderer) bxmlserializer.readobject(customlistrenderer.class, "customlistrenderer.bxml"); } // rest of stuff here }
then put snippet above customlistrenderer.bxml, change root item customlistrenderer:
<my:customlistrenderer styles = "{padding : 5, horizontalspacing : 5, verticalspacing : 5}" xmlns:bxml="http://pivot.apache.org/bxml" xmlns:my="your.java.package.here" xmlns="org.apache.pivot.wtk"> ... rest of bxml here ...
finally, when create listview wants use custom renderer, can do
listview.setitemrenderer(customlistrenderer.create());
Comments
Post a Comment