• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

ItemStateListener and itemStateChanged()

 
Layne Lund
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I recently bought the book Core J2ME Technology and am working through the examples. I'm having a problem with the ItemStateListner stuff. I understand that the MIDP specification says that itemStateChanged() doesn't have to be called every time a change occurs. However, I don't understand why this is.
In fact, in the first example for ItemState events on page 117, the itemStateChanged() method is never called. I can change the DateField item as many times as I want, and it still isn't called.
I thought this might just be a fluke, but I came to a similar example for a snooze MIDlet. The same thing happens: when the date/time is changed the event never fires.
What is going on here? What's the point of an event handler that is never called? I'm very confused about this issue.
I know I should probably post some code, but I think that might be a bit premature at this point. If you have the book, the examples are on page 117 (CaptureItemEvents.java) and page 132 (Snooze.java).
I am developing with the Linux version of MIDP. Perhaps it has to do with this specific implementation?
Any comments will be greatly appreciated.
Regards,
Layne
 
john muchow
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
>In fact, in the first example for ItemState
>events on page 117, the itemStateChanged()
>method is never called. I can change the
>DateField item as many times as I want, and it
>still isn't called.
This must be an error with the implementation.
If you look at page 119, you will see the screen shot that I captured (right most figure), showing the result once the event is executed.
What implementation are you using? Feel free to forward the examples to the developers to show the problem.
Regards,
John Muchow
john@corej2me.com
 
Layne Lund
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry, I forgot to mention the developer. I'm using Sun's implementation for Linux. I guess I assumed that their own implementation would handle this correctly. I thought I'd done something wrong. Maybe I just need to go over the code to make sure it is the exact same as the listing in your book...
 
john muchow
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Layne,
When you have a chance, send me the code you have written. Although I don't have the Linux install, I will run the code on my machine and see if it runs.
If it does, we can decide how to proceed from there.
Thanks,
John
john@corej2me.com
 
Layne Lund
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Will do. I also downloaded the source code from your site so I can do a diff with the code I typed in. Usually I avoid downloading source code because typing the examples usually helps me learn the concepts better.
Well, thank you for your time. I sure would like to figure out what the problem is...
Layne
 
David Carlson
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Now it's 12/14/2004 I'm having the same itemStateListener issues. What was the solution?
 
Edward Durai
Ranch Hand
Posts: 223
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Steps :1

implements the itemStateListener in class

Step :2

add method like public void itemStatechanged(Item item){
++++++action+++++
}

step :3

add itemStateListener
display.setCurrent(form);

Thanks
further
edward_durai@hotmail.com
 
Andrea Cacciarru
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have the same problem too. If I try Muchow's example in my Sun wireless toolkit everything works fine, but if I try Snooze example in my LG U8180 mobile, the itemStateChanged don't works! Maybe can it depend by the LG's JVM implementation?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic