如何以编程方式知道实际修改的组件?
在 J2ME 中,有一个接口 ItemStateListener
,它可以准确检测正在更改
的项目。 LWUIT 有类似的方法吗?我尝试使用 DataChangedListener 接口,但它为 index
参数提供了 TextField 内的字符位置,或 -1 !所以 ....
In J2ME there is the interface ItemStateListener
which can detect exactly the item which is being changed
. Is there a similar way in LWUIT ? I tried using the DataChangedListener
interface but it gives the character position within the TextField , or -1 , for the index
argument ! So ....
最初将布尔值设置为 false 并添加组件的侦听器,然后如果该组件上发生任何事件,则将布尔值设置为 true。对组件使用
addDataChangeListener
(仅适用于TextField
)或addActionListener
。addDataChangeListener
返回两个索引值。最初返回 -1,然后返回TextField
的当前文本位置。 AFAIK 在TextField
上,他们在setText
方法上为fireDataChanged
设置默认索引值为 -1。这就是为什么它最初会返回-1。Initially set the
boolean
value to false and add the listener for the components then if any event occurs on that components, set the boolean value to true. Use theaddDataChangeListener
(It only forTextField
) oraddActionListener
for the components. OnaddDataChangeListener
returns two index values. Initially returns -1 and then returns current text position of theTextField
. AFAIK OnTextField
, they set the default index value is -1 forfireDataChanged
onsetText
method. That is why it will returns -1 initially.