the same with the toolbar tutorial. im going to split these tutorial into parts. These Part 1 will be consist of any stuff that pretty much simple.
Requirements :
- Blackberry OS 5
- Java Eclipse Plugin for Blackberry
today i want to create a simple tutorial from simple ListField to a complex and custom ListField.
maybe not tutorial but a review from the resources over the internet.
if you want to know the differences from objectListField here some article or maybe an answer for you :
http://stackoverflow.com/questions/3573941/how-to-customize-objectlistfield
Syntax Highlight by http://tohtml.com/java/
lets starts with the one that blackberry have on How to - Make list items appear on a screen.
with their code here is what you'll get.
it is an empty string but the list field is there. i think you can scroll it down
Blackberry ListField with Text
now its something that i got from books.
with that code you'll get this list field with text :
it doesn't have click able field. and its still just one field per row.
next time i'll try to make more interesting. Please read the Part 2 of the tutorial its Listfield that support Image.
Go to Part 2
Requirements :
- Blackberry OS 5
- Java Eclipse Plugin for Blackberry
today i want to create a simple tutorial from simple ListField to a complex and custom ListField.
maybe not tutorial but a review from the resources over the internet.
if you want to know the differences from objectListField here some article or maybe an answer for you :
http://stackoverflow.com/questions/3573941/how-to-customize-objectlistfield
Syntax Highlight by http://tohtml.com/java/
lets starts with the one that blackberry have on How to - Make list items appear on a screen.
with their code here is what you'll get.
it is an empty string but the list field is there. i think you can scroll it down
Blackberry ListField with Text
now its something that i got from books.
import net.rim.device.api.ui.Color; import net.rim.device.api.ui.Font; import net.rim.device.api.ui.Graphics; import net.rim.device.api.ui.component.ListField; import net.rim.device.api.ui.component.ListFieldCallback; import net.rim.device.api.ui.container.MainScreen; public class test2Screen extends MainScreen implements ListFieldCallback { protected String listMembers[] = {"itema1","itemb2","itemc3","itemd4"}; /* * From The Book Blackberry Java Application Development */ public test2Screen() { super(MainScreen.VERTICAL_SCROLL | MainScreen.VERTICAL_SCROLLBAR); // TODO Auto-generated constructor stub ListField mylist = new ListField(); mylist.setCallback(this); mylist.setSize(4); add(mylist); } public void drawListRow(ListField listField, Graphics graphics, int index, int y, int width) { // TODO Auto-generated method stub //graphics.drawText("test"+Integer.toString(index),0,y,0,50); graphics.setColor(Color.BLUE); graphics.setBackgroundColor(Color.YELLOW); graphics.setFont(Font.getDefault().derive(Font.BOLD)); graphics.drawText(this.listMembers[index], 0, y,50); } public Object get(ListField listField, int index) { // TODO Auto-generated method stub return listMembers[index]; } public int getPreferredWidth(ListField listField) { // TODO Auto-generated method stub return 200; } public int indexOfList(ListField listField, String prefix, int start) { // TODO Auto-generated method stub return -1; } }
with that code you'll get this list field with text :
it doesn't have click able field. and its still just one field per row.
next time i'll try to make more interesting. Please read the Part 2 of the tutorial its Listfield that support Image.
Go to Part 2
Comments