|
package KnowledgeBase;
import net.rim.device.api.ui.*;
import net.rim.device.api.ui.container.*;
import net.rim.device.api.ui.component.*;
import net.rim.device.api.system.Bitmap;
class HomeScreen extends MainScreen {
private String mnuSearchTitles;
private String mnuBrowseTags;
private String mnuViewRecent;
private String[] mainMenuItems;
private MyObjectListField menu;
HomeScreen() {
this.setTitle("KnowledgeBase");
menu = new MyObjectListField();
mnuSearchTitles = "Search by Title";
mnuBrowseTags = "Browse Tags";
mnuViewRecent = "View Recent";
mainMenuItems = new String[]{mnuSearchTitles,mnuBrowseTags,mnuViewRecent};
menu.set(mainMenuItems);
this.add(menu);
}
protected boolean navigationClick(int status, int time) {
// Determine which menu item was clicked.
int selected = menu.getSelectedIndex();
switch (selected) {
case 0:
// TODO: Show the Search Screen.
break;
case 1:
// TODO: Show the Browse Tags Screen.
break;
case 2:
// TODO: Show the Results Screen and load the
// recently viewed items.
break;
}
return true;
}
private class MyObjectListField extends ObjectListField {
private Bitmap icon = Bitmap.getBitmapResource("img/star_green.png");
// We are going to take care of drawing the item.
public void drawListRow(ListField listField, Graphics graphics,
int index, int y, int width) {
if (null != icon) {
int offsetY = (this.getRowHeight() - icon.getHeight())/2;
graphics.drawBitmap(1,y + offsetY, icon.getWidth(),
icon.getHeight(),icon,0,0);
graphics.drawText(mainMenuItems[index],
icon.getWidth() + 2, y, DrawStyle.ELLIPSIS, width);
} else {
graphics.drawText("- " + mainMenuItems[index], 0,
y, DrawStyle.ELLIPSIS, width);
}
}
};
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.