我在黑莓中使用ListField
,無法應用row.setChangeListener
。 任何人都可以幫我嗎? 這裏是我的代碼,BlackBerry - 如何將clickEvent(setChangeListener)添加到BlackBerry中的ListField?
Friendship objFriendship = new Friendship();
friends = objFriendship.FetchFriends(AATTGlobals.CURRENT_USER.getUserID());
rows = new Vector();
for (int x = 0; x < friends.length; x++) {
String UserName = friends[x].getUserName();
ProfilePicture = MISC.FetchUserProfilePicture(friends[x].getProfilePicturePath());
String Location = friends[x].getLocation();
TableRowManager row = new TableRowManager();
row.add(new BitmapField(ProfilePicture));
LabelField task = new LabelField(UserName,DrawStyle.ELLIPSIS)
{
protected void paint(Graphics graphics) {
graphics.setColor(0x0099CCFF);
super.paint(graphics);
}
};
task.setFont(Font.getDefault().derive(Font.BOLD));
row.add(task);
row.add(new LabelField(Location,DrawStyle.ELLIPSIS)
{
protected void paint(Graphics graphics) {
graphics.setColor(0x0099CCFF);
super.paint(graphics);
}
}
);
row.setChangeListener(new FieldChangeListener() {
public void fieldChanged(Field field, int context) {
Dialog.alert("Row Clicked #");
}
});
沒有任何錯誤消息,但setChangeListener
不火,這裏是TableRowManager
Private class TableRowManager extends Manager {
public TableRowManager() {
super(0);
}
public void drawRow(Graphics g, int x, int y, int width, int height) {
layout(width, height);
setPosition(x, y);
g.pushRegion(getExtent());
subpaint(g);
g.setColor(0x0099CCFF);
g.drawLine(0, 0, getPreferredWidth(), 0);
g.popContext();
}
protected void sublayout(int width, int height) {
int fontHeight = Font.getDefault().getHeight();
int preferredWidth = getPreferredWidth();
Field field = getField(0);
layoutChild(field, 44, 44);
setPositionChild(field, 10, getRowHeight()/4);
field = getField(1);
layoutChild(field, preferredWidth - 16, fontHeight + 1);
setPositionChild(field, 70, getRowHeight()/5);
field = getField(2);
layoutChild(field, field.getPreferredWidth(), fontHeight + 1);
setPositionChild(field, 70, (getRowHeight()/2) + 5);
setExtent(preferredWidth, getPreferredHeight());
}
public int getPreferredWidth() {
return Graphics.getScreenWidth();
}
public int getPreferredHeight() {
return getRowHeight();
}
}
是否有錯誤訊息?什麼是TableRowManager? –
什麼是TableRowManager()在你的application.let中我知道代碼然後只有任何人都可以幫助你。所以請附上您的TableRowManager()代碼。 –
你確定使用'ListField'嗎?您提供的代碼中沒有'ListField'實例。 –