问题
I am developing an application where I need to use list-field. Inside each list-field item, there are three fields:
Image Text Image
If I click on the list-field item a menu is displayed. But I don't want the whole list field item row to be selected when the user clicks the row. I want a part of the list-field item highlighted -- if I click the first image one action should be performed, and if I click the last image after the text another action should be performed. Now wherever I click on the list-field item same action is being performed. I don't want it. I want separate actions for different fields inside each list-field item.
回答1:
If the API does not support it, the API does not support it. A common J2ME problem.
Consider creating your own CustomItem.
回答2:
You can customize ListField to do what you want. Keep in mind that ListField does not have separate Field objects on each row - it just draws the entire row at once, and you provide the paint method to do it. So your mental model appears to be somewhat incorrect, since you are thinking of these as fields.
You will need to override the focus behavior, and the trackpad movement. Then you can draw each row with the appropriate part of the list item focused. You will have to manage that yourself.
If you are supporting touch devices, you will also need to handle touch events, to figure out what part of the row was touched.
来源:https://stackoverflow.com/questions/5092471/how-to-fire-an-event-for-different-fields-inside-list-field-item-in-blackberry