Pregunta

I am preparing for a new app, just want to create a TextField.

I have to provide functionality to select a portion of text and change its color. For example: hello, I am blackberry developer. Now I want to change the font color of blackberry developer at runtime.

Is it possible in EditField or BasicEditField or RichTextField in any one??? Thanxx in advance!:)

¿Fue útil?

Solución

LabelField labelField2 = new LabelField("hello, I am blackberry developer",Field.FOCUSABLE){

        boolean _inFocus = false;
        public void onFocus(int direction) {
            _inFocus = true;
            this.invalidate();
        }
        public void onUnfocus() {
            _inFocus = false;
            this.invalidate();
        }
        protected void paint(Graphics graphics) {
             if(_inFocus){
                 graphics.setColor(Color.BLUE);
             }else{
                 graphics.setColor(Color.RED);
         }
          super.paint(graphics);
       }
       protected void drawFocus(Graphics g, boolean on) {
      }
    };

Enjoy...

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top