05-08-2012 07:06 AM
I am having an custom edit field with image which i am setting in its paint background method.
My custom edit field class extends horizontal scroll as i need it. but still input is not in one line while i am setting property EditField.No_Newline.
alternatively, I added some piece of code in my paint to do so...
but its updating my MainScreen scroll ......what to do pls help...
EditField ef = (EditField)getField(0);
String entireText = ef.getText();
boolean longText = false;
String textToDraw = "";
font = getFont();
int availableWidth = width - totalHorizontalEmptySpace;
if (font.getAdvance(entireText) <= availableWidth)
textToDraw = entireText;
int endIndex = entireText.length();
for (int beginIndex = 1; beginIndex < endIndex; beginIndex++)
textToDraw = entireText.substring(beginIndex);
if (font.getAdvance(textToDraw) <= availableWidth)
longText = true;
if (longText == true)
// Force the edit field display only the truncated text
// Now let the components draw themselves
// Return the text field its original text
05-08-2012 07:09 AM
05-08-2012 09:04 AM
VerticalFieldManager vfm = new VerticalFieldManager(this.HORIZONTAL_SCROLL | USE_ALL_WIDTH | USE_ALL_HEIGHT);
EditField e = new EditField("Username","");
if you do use this code. Then the text will be in single line. Henceforth, you customize this as your need.
Press Like, if you find this code is helpful to you.