Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Custom List

 
Ofer Gurman
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does anyone know of a custom item which implements a custom list?
 
Michael Yuan
author
Ranch Hand
Posts: 1427
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
O Gur,

Please change your display name to conform to the JavaRanch naming policy, which you had agreed to when you signed up.

thanks.
Michael (the moderator)
 
Ofer Gurman
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oh sorry.
Back to my question, can you help me please, I need to write a custom item that implements a list behavior (MUST support text wrapping). I have succeeded in most parts of the custom item but for the text wrapping.

Thanks,

Ofer.
 
Yuri Magrisso
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ofer,

There is no component or class that provides what you need in MIDP. I also had to do something like that. For the text-wrapping part I wrote a function that takes a string and divides it into lines based on the width available.

What you need is Canvas.getWidth() to see what is the maximum width of the screen and then Font.getCharWidth() to find out how many chars can you have in one line. You should also check for whitespace to break on word boundary.
 
Michael Yuan
author
Ranch Hand
Posts: 1427
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ofer,

Your name still does not conform to the requirement. Please read the link I provided above. You need a first name and a last name.

In MIDP 2, the Choice.TEXT_WRAP_DEFAULT variable controls whether the item wraps text. There is no need for a custom item.
 
Yuri Magrisso
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ups, I have missed this one. Always good to learn something new, though.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic