How do I handle it? The default BlackBerry text edit box is able to wrap, how can I make EditField do not change lines?

Source: Internet
Author: User
Tags gettext

A simple solution:

You can set the EditField cannot accept the ENTER key and set the maximum number of characters.

EditField Loginidfield = new EditField ("Login", "Hello", Max_chars, Editfield.no_newline);

However, if the user is typing a character that is less than the maximum number of characters, but exceeds the length of the EditField, EditField will still wrap the line.

Solution:

Create a custom component that puts the EditField in the HorizontalFieldManager, and HorizontalFieldManager uses horizontal_scroll style to not break the line but can input many characters, Even if it's too long, it won't wrap.

* Http://www.dogizmo.com/gadget/sample-code-scrollable-one-line-text-input-field * *
Package Com.rim.samples.device.helloworlddemo;

Import Net.rim.device.api.system.Display;
Import Net.rim.device.api.ui.component.EditField;
Import Net.rim.device.api.ui.component.ListField;
Import Net.rim.device.api.ui.container.HorizontalFieldManager;

public class Onelinetextfield extends HorizontalFieldManager {
Private EditField _editfield;

Public Onelinetextfield (String label, string initialvalue, int maxchars, long style) {
Super (Horizontal_scroll);
_editfield = new EditField (label, InitialValue, Maxchars, style | Editfield.no_newline | editfield.focusable | editfield.editable);
Add (_editfield);
}
/*

protected void sublayout (int maxwidth, int maxheight) {
Super.sublayout (Getpreferredwidth (), maxheight);
}


 public int getpreferredwidth ()
    {
        return 200;
   }
*/
   
    public String getText () {
         return _editfield.gettext ();
   }
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.