У меня есть встроенный ListField на BlackBerry. Как добавить 3 ярлыка в список?Добавить ярлык на BlackBerry ListField
2
A
ответ
1
этого учебного курса: http://berrytutorials.blogspot.com/2009/11/create-custom-listfield-change.html
После завершения редактирования расширенного класса ListField путем добавления некоторых дополнительных компонентов в список (graphics.drawText (CALLBACK OBJECT, X, Y)). Измените обратный вызов String на объект вашего типа (или просто массив) с доступностью для большего количества элементов.
Пример красочного МЕТОДА внутри расширенного ListField Класс:
public void paint(Graphics graphics) {
int width = (int) (300 * resizeWidthFactor);
// Get the current clipping region
XYRect redrawRect = graphics.getClippingRect();
// Side lines
// graphics.setColor(Color.GRAY);
// graphics.drawLine(0, 0, 0, redrawRect.height);
// graphics.setColor(Color.GRAY);
// graphics.drawLine(redrawRect.width-1, 0, redrawRect.width-1,
// redrawRect.height);
if (redrawRect.y < 0) {
throw new IllegalStateException("Error with clipping rect.");
}
// Determine the start location of the clipping region and end.
int rowHeight = getRowHeight();
int curSelected;
// If the ListeField has focus determine the selected row.
if (hasFocus) {
curSelected = getSelectedIndex();
} else {
curSelected = -1;
}
int startLine = redrawRect.y/rowHeight;
int endLine = (redrawRect.y + redrawRect.height - 1)/rowHeight;
endLine = Math.min(endLine, getSize() - 1);
int y = (startLine * rowHeight) + heightMargin;
// Setup the data used for drawing.
int[] yInds = new int[] { y, y, y + rowHeight, y + rowHeight };
int[] xInds = new int[] { 0, width, width, 0 };
// Set the callback - assuming String values.
ListFieldCallback callBack = this.getCallback();
// Draw each row
for (; startLine <= endLine; ++startLine) {
// If the line we're drawing is the currentlySelected line then draw the
// fill path in LIGHTYELLOW and the
// font text in Black.
//OBJECT OF OWN TYPE FOR MULTIPLE PARAMETERS
ProductDetails data = (ProductDetails) callBack.get(this, startLine);
String productDescription = "";
String errorDescription = "";
if (data.isError()) {
errorDescription = TextLineSplitter.wrapString1Line(data.getErrorMessage(), (int) ((300 - (2 * widthMargin)) * resizeWidthFactor), getFont());
} else {
productDescription = TextLineSplitter.wrapString1Line(data.getProductDesc(), (int) ((300 - (2 * widthMargin)) * resizeWidthFactor), getFont());
}
// Set differences by row (selected or not)
if (startLine == curSelected) {
graphics.setColor(Color.WHITE);
} else {
// Draw the odd or selected rows.
graphics.setColor(Color.BLACK);
}
// Set text values
if (!data.isError()) {
// If no error found
//FIRST LABEL
graphics.setFont(getFont().derive(Font.BOLD));
graphics.drawText("Result search " + Integer.toString(data.getSearchId()) + ":", widthMargin, yInds[0]);
graphics.drawText(data.getManufacturerItemIdentifier(), widthMargin + (int) (140 * resizeWidthFactor), yInds[0]);
//SECOND LABEL
graphics.setFont(getFont().derive(Font.PLAIN));
graphics.drawText(productDescription, widthMargin, yInds[0] + (int) (20 * resizeHeightFactor));
} else {
// Error found
graphics.setColor(Color.GRAY);
graphics.setFont(getFont().derive(Font.BOLD));
graphics.drawText("Result search " + Integer.toString(data.getSearchId()) + ":", widthMargin, yInds[0]);
graphics.setFont(getFont().derive(Font.PLAIN));
graphics.drawText(errorDescription, widthMargin, yInds[0] + (int) (20 * resizeHeightFactor));
}
// Bottom line
if (startLine == endLine) {
graphics.setColor(Color.GRAY);
graphics.drawLine(0, yInds[2] - (heightMargin + 1), (int) (300 * resizeWidthFactor), yInds[2] - (heightMargin + 1));
}
// Horizontal lines
graphics.setColor(Color.GRAY);
graphics.drawLine(0, yInds[0] - heightMargin, (int) (300 * resizeWidthFactor), yInds[0] - heightMargin);
// Assign new values to the y axis moving one row down.
y += rowHeight;
yInds[0] = y;
yInds[1] = yInds[0];
yInds[2] = y + rowHeight;
yInds[3] = yInds[2];
}
// super.paint(graphics);
}
Смежные вопросы
- 1. Blackberry ListField Item Сепаратор
- 2. Добавить ButtonField в строке ListField в blackberry
- 3. Blackberry - ListField макет вопрос
- 4. Custom ListField Blackberry
- 5. Blackberry ListField цвет выделения
- 6. Отобразить EditField в ListField BlackBerry
- 7. Как переустановить ListField в Blackberry
- 8. Выделение элемента в Blackberry ListField
- 9. Обтекание текстом в строке ListField на BlackBerry
- 10. Как настроить listfield в blackberry?
- 11. Как настроить ListField в BlackBerry?
- 12. Рисование границы в BlackBerry ListField
- 13. Горизонтальная прокрутка BlackBerry в TreeField или ListField
- 14. Blackberry - Sort ListField данные по дате
- 15. Blackberry - предотвращает прокрутку ListField после удаления элемента
- 16. Добавление компонентов пользовательского интерфейса в Blackberry ListField
- 17. Как создать таблицу, такую как blackberry listfield?
- 18. Как проверить onchildclick в blackberry listfield?
- 19. Создать ListField с изображением в BlackBerry
- 20. Blackberry - Как реализовать ListField Smooth Scrolling?
- 21. Custom ListField с флажками в Blackberry
- 22. Как создать пользовательский listField?
- 23. blackberry - добавить поля на экран
- 24. Добавить ContactList на Blackberry
- 25. Многострочный пользовательский ярлык в blackberry
- 26. Blackberry - Как сделать перенос текста в ListField с флажками?
- 27. В Listfield не удалось просмотреть поля в blackberry
- 28. Blackberry Custom Background of VFM scrolls with listfield?
- 29. Blackberry Listfield с переменной высотой для каждой строки?
- 30. Blackberry-ListField с изображениями из URL (XML DATA)