BlackBerry-如何将clickEvent(setChangeListener)添加到BlackBerry中的列表字段?
我正在Blackberry中使用BlackBerry-如何将clickEvent(setChangeListener)添加到BlackBerry中的列表字段?,blackberry,Blackberry,我正在Blackberry中使用ListField,无法应用行。setChangeListener。 谁能帮帮我吗? 这是我的密码 Friendship objFriendship = new Friendship(); friends = objFriendship.FetchFriends(AATTGlobals.CURRENT_USER.getUserID()); rows = new Vector(); for (int x = 0; x < friends.leng
ListField
,无法应用行。setChangeListener
。
谁能帮帮我吗?
这是我的密码
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 #");
}
});
在tableRowManager中添加以下内容
//for non touch
protected boolean navigationClick(int status, int time) {
fieldChangeNotify(0);
return true;
}
//for touch
protected boolean touchEvent(TouchEvent message) {
if (TouchEvent.CLICK == message.getEvent()) {
FieldChangeListener listener = getChangeListener();
if (null != listener)
listener.fieldChanged(this, 1);
}
return super.touchEvent(message);
}
试试这个,让我知道它是否工作。在tableRowManager中添加这个
//for non touch
protected boolean navigationClick(int status, int time) {
fieldChangeNotify(0);
return true;
}
//for touch
protected boolean touchEvent(TouchEvent message) {
if (TouchEvent.CLICK == message.getEvent()) {
FieldChangeListener listener = getChangeListener();
if (null != listener)
listener.fieldChanged(this, 1);
}
return super.touchEvent(message);
}
试试这个让我知道它是否工作。我注意到,fieldChangeLister/FieldChanged没有被ListField UI调用[因为它适用于按钮和标签。]所以我认为ListField不支持FieldChanged
在navigationClick/TouchEvent()中,在FieldChange方法中写入您正在编写的操作。我注意到,ListField UI不会调用fieldChangeLister/FieldChanged[因为它适用于按钮和标签。]因此我认为ListField不支持FieldChanged
在navigationClick/TouchEvent()中,在FieldChange方法中写入您正在编写的操作。是否有错误消息?什么是TableRowManager?应用程序中的TableRowManager()是什么。请告诉我该代码,然后只有任何人可以帮助您。因此,请同时附加TableRowManager()代码。您确定要使用
ListField
?您提供的代码中没有ListField
实例。是否有错误消息?什么是TableRowManager?应用程序中的TableRowManager()是什么。请告诉我该代码,然后只有任何人可以帮助您。因此,请同时附加TableRowManager()代码。您确定要使用ListField
?您提供的代码中没有ListField
实例。它不起作用。我们在别的地方写过其他代码吗?它不起作用。我们在其他地方写过其他代码吗?