[英]How to display Integer values in a BlackBerry Table
我需要在表格中顯示“整數”類型的值。 現在,我認為要做的就是簡單地檢查DataTemplate的“ getDataFields()”方法中的“ Integer”類型,並將此DataTemplate設置為TableView的數據模板。
下面的屏幕截圖顯示了我的“ getDataFields”方法。 在模擬器上運行此代碼后,我只是得到了NoClassDefFoundError。
你們有任何想法要怎么做嗎?
設置:BB Eclipse插件v1.3,SDK 6.0
開始了 :)
(注意:我將類型更改為Double而不是Integer,但是工作方式相同)
public void setStyle() {
DataTemplate dataTemplate = new DataTemplate(tableView, NUM_ROWS,
NUM_COLUMNS) {
public Field[] getDataFields(int modelRowIndex) {
Object[] data = (Object[]) _tableModel.getRow(modelRowIndex);
Field[] fields = new Field[data.length];
for (int i = 0; i < data.length; i++) {
if (data[i] instanceof Bitmap) {
fields[i] = new BitmapField((Bitmap) data[i]);
} else if (data[i] instanceof String) {
MyTextField cell;
if(i==0){
cell = new MyTextField((String) data[i], RichTextField.NON_FOCUSABLE);
} else {
cell = new MyTextField((String) data[i], RichTextField.NON_FOCUSABLE | RichTextField.TEXT_ALIGN_RIGHT);
}
if(rowCount%2==0){
Background bg = BackgroundFactory.createSolidBackground(DesignColors.LIGHTBLUE);
cell.setBackground(bg);
}
fields[i] = cell;
} else if (data[i] instanceof Double){
MyTextField cell = new MyTextField("Double", RichTextField.FOCUSABLE);
if(rowCount%2==0){
Background bg = BackgroundFactory.createSolidBackground(DesignColors.LIGHTBLUE);
cell.setBackground(bg);
}
fields[i] = cell;
} else {
fields[i] = (Field) data[i];
}
}
rowCount++;
return fields;
}
};
tableView.setDataTemplate(dataTemplate);
}
我實際想要做的如下所示:
Vector atx = new Vector();
atx.addElement("ATX");
atx.addElement(2885.19);
atx.addElement("-0,14");
kurse.addElement(atx);
所以我用幾個向量填充“ kurse”向量。 示例中的“ atx”中的Vector包含不同的元素,即Strings和Doubles。 我需要用不同的類型傳遞它們,因為字符串的樣式將不同於Doubles。
使用上面的代碼給我NoClassDefFoundError,將值傳遞為String,就像
atx.addElement("2885.19");
完美地工作。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.