Reputation: 877
i have written a class which implements ListFieldCallBack like,
import java.util.Vector;
import net.rim.device.api.ui.Graphics;
import net.rim.device.api.ui.component.ListField;
import net.rim.device.api.ui.component.ListFieldCallback;
class ListCallBack implements ListFieldCallback
{
private Vector listelements = new Vector();
public void drawListRow(ListField listField, Graphics graphics, int index, int y, int width)
{
String text = (String)listelements.elementAt(index);
graphics.drawText(text,0,y,0,width);
}
public Object get(ListField listField, int index)
{
return listelements.elementAt(index);
}
public int indexOfList(ListField listField, String prefix, int start)
{
return listelements.indexOf(prefix, start);
}
public int getPreferredWidth(ListField listField)
{
return Graphics.getScreenWidth();
}
public void insert(String toInsert, int index)
{
listelements.addElement(toInsert);
}
public void erase()
{
listelements.removeAllElements();
}
}
And in my constructor having the main class is coded as
helloWorld()
{
mylist = new ListField();
ListCallBack myCallBack = new ListCallBack();
mylist.setCallback(myCallBack);
for(int i = 0; i<array.length;i++)//array is a string array
{
list_category.insert(i);
myCallBack.insert(array[i], i);
}
this.add(list_category);
}
this works properly..
like, i am getting output like,
Aby
Eric
Allay
vine
But i want to add another string to the next of that array in the each row displayed in list.. How could i do this?
Like, for example, i want my screen output like,
Aby : Smart
Eric : 0000
Allay : 9789
vine : Like
how could i do this?
Upvotes: 0
Views: 236
Reputation: 28418
You should change the ListFieldCallback.drawListRow(ListField listField, Graphics graphics, int index, int y, int width)
to draw that.
Use net.rim.device.api.ui.Graphics
API to draw whatever you want.
Upvotes: 1