0
public class CategoriesUI extends MainScreen implements ListFieldCallback {
//categoryimport.listingnodup is the current categories with no duplicates
public Categories categoryimport = new Categories(); //brings in all infromation from Categories.java
BitmapField bitmapField;
Bitmap nextselection = Bitmap.getBitmapResource("nextselection.png");
HorizontalFieldManager _hfm;
VerticalFieldManager _vfm;
private ListField allcategories;
CategoriesUI() {
try {
FontFamily alphaSansFamily = FontFamily.forName("BBClarity");
Font appFont = alphaSansFamily.getFont(Font.PLAIN, 12, Ui.UNITS_pt);
setFont(appFont);
} catch (ClassNotFoundException e) {
}
allcategories = new ListField(categoryimport.listingnodup.size());
allcategories.setCallback(this); //we manage the interaction!
//Get the device wudth and height
final int width = Display.getWidth();
final int height = Display.getHeight();
//Draw background gradient on this manager and add VerticalfieldManager for scrolling
_hfm = new HorizontalFieldManager() {
//Sublayout is passed the width and height of the partent window and will tell the window manager
//how to layout hte buttons, images, etc.
protected void sublayout(int w, int h) {
//GetFieldCount returns the number of fields attached to the instance of this manger.
//and lays out the postition
if (getFieldCount() > 0){
Field searchRes = getField(0);
layoutChild(searchRes, width, height);
setPositionChild(searchRes, 0, 0);
}
setExtent(width, height);
}
};
_vfm = new VerticalFieldManager(Manager.VERTICAL_SCROLL|Manager.USE_ALL_HEIGHT|Manager.USE_ALL_WIDTH) {
protected boolean nagivationClick(int status, int time) {
categoryimport.sections();
nextscreen();
return true;
}
public void paint (Graphics g) {
//Variables for drawing the gradient
int[] X_PTS_MAIN = { 0, width, width, 0 };
int[] Y_PTS_MAIN = { 0, 0, height, height };
int[] drawColor_MAIN = { Color.GRAY, Color.GRAY, Color.DARKGRAY, Color.DARKGRAY};
try {
//Draw the gradients
g.drawShadedFilledPath(X_PTS_MAIN, Y_PTS_MAIN, null, drawColor_MAIN, null);
} catch (IllegalArgumentException iae) {
System.out.println("Bad Arguments.");
}
super.paint(g);
}
};
_vfm.add(new LabelField("List of Categories"));
_vfm.add(allcategories);
_hfm.add(_vfm);
add(_hfm);
}
//Get screen width and image width to move the image to the far right
int screenwidth = Display.getWidth();
int imagewidth = nextselection.getWidth();
int pushimagetoright = screenwidth - imagewidth;
//Returns the object at the specified index
public Object get(ListField list, int index)
{
return categoryimport.listingnodup.elementAt(index);
}
//Implemented Call Back Methods follow
//draw the current row
public void drawListRow(ListField list, Graphics g, int index, int y, int w) {
Object catdrawer = get(list, index);
g.setColor(Color.BLACK);
if(g.isDrawingStyleSet(Graphics.DRAWSTYLE_FOCUS)) {
g.setGlobalAlpha(255);
g.drawBitmap(pushimagetoright, y, nextselection.getWidth(), nextselection.getHeight(), nextselection, 0, 0);
invalidate();
} else {
g.setGlobalAlpha(50);
g.drawBitmap(pushimagetoright, y, nextselection.getWidth(), nextselection.getHeight(), nextselection, 0, 0);
}
if(catdrawer != null) {
String drawer = catdrawer.toString();
if (drawer != null) {
g.drawText(drawer, 0, y, 0, w);
}
}
}
public int getPreferredWidth(ListField list) {
return Display.getWidth();
}
public int indexOfList(ListField listField, String prefix, int start) {
return start;
}
public void nextscreen() {
int catnum = allcategories.getSelectedIndex();
Object button = categoryimport.listingnodup.elementAt(catnum);
categoryimport.categorysecondlvl = button.toString();
if (categoryimport.namelisting.capacity() != 0) {
categoryimport.namelisting.removeAllElements();
}
Categoriessndlvl categorysecondlvl = new Categoriessndlvl();
UiApplication.getUiApplication().pushScreen(categorysecondlvl);
}
}
的NavigationClick當我運行模擬器8800-JDE上JDE 4.2.1我相信它需要被放置在一個FieldManager不調用,這是什麼,我相信我完成了。因此,我的問題是如何調用navigationclick,所以當點擊軌跡球時,它可以繼續運行不同的功能?關聯使用navigationclick與黑莓listfield