Skip to main content

BlackBerry ListField Tutorial Part 1

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.

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

Popular posts from this blog

JavaScript Real Time Calculation

I've been around looking for javascript that can do Real Time Calculation. javascript real time calculation, javascript real time calculation textbox. by some lucky keywords i found this code. this is exactly the code that i want. it really do the real time calculation. and it doesn't need onChange or OnBlur function. Just try it Example + = this is the javascript code <script type='text/javascript' > function startCalc(){   interval = setInterval("calc()",1); } function calc(){   one = document.autoSumForm.firstBox.value;   two = document.autoSumForm.secondBox.value;   document.autoSumForm.thirdBox.value = (one * 1) + (two * 1); } function stopCalc(){   clearInterval(interval); } </script> this is the html code <form name="autoSumForm">   <input class="right" type=text name="firstBox" value="" onFocus="startCalc();" onBlur="stopCalc();"><br...

BlackBerry ListField Tutorial Part 3

This Part 3 will consist of Networking, ListField, JSON and Thread. I'm really sorry for pending this part 3. I've been busy making money and still failed. Its just really hard to live in third world country by coding. anyway, There are few Library that you will need creating ListField with JSON data, but we wont touch that area first. we need to learn the basic. * note added : Aug 26 2013 The basic should be : Networking Thread ListField [if i find anything, will be add here]

iOS 5 Creating eCommerce with Shopping Cart App Part 1

[Created 11-28-2012] it seems like there are tons of tutorial ios and xcode for beginner out there. you can view the list at my post here http://javalearning-adventure.blogspot.com/2012/11/learning-xcode.html that's the link that i always update if i find anything. this tutorial will consist of step by step in creating Shopping Cart App. There will be Browse Product, Shopping Cart, and Checkout Method. I will update these later after i satisfied with the end result. These tutorial will also include web programming using php. but these php will only using basic sample not the very complex with mysql database and everything. these php pages will only creating json output. i think you don't need to learn php and json. you should only learn how to handle json using objective-c. I am still a beginner in xcode and objective-c, its still only 1 month since i started these tutorial. requirements suppose to be iOS 5 with xcode 4. [i will update these later][postponed...