Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Developer
ravi1989
Posts: 773
Registered: ‎07-21-2012
My Device: 9810
My Carrier: 0

How to make scroll able custom round edit field

Hi 

 

can you please tell me How to make scroll able custom round edit field  .

search-screen.JPG

Please use plain text.
Developer
peter_strange
Posts: 19,598
Registered: ‎07-14-2008
My Device: Not Specified

Re: How to make scroll able custom round edit field

The round edge is just a Border.  If you search for Border in the forum you should find instructions for doing what you want.  In addition, look at the Border class in the API.  You may have to ask someone familiar with drawing packages to create the curved edge Border for you. 

 

Making a scrolling text input Field has also been discussed at length on the forum.  Please search for this as well.

Please use plain text.
Developer
ravi1989
Posts: 773
Registered: ‎07-21-2012
My Device: 9810
My Carrier: 0

Re: How to make scroll able custom round edit field

Hello i searched ..i found good solution but i struck in middle  .Problem is that my  search edit field is in middle of the sreen .so i want to add my field in middle of the my screen .

i can used two method 

1) setmargin   //

2) paint method (but in paint method i am not able to do that).

package com.blacks.app.mobile.ui.component;

import net.rim.device.api.system.Bitmap;
import net.rim.device.api.ui.Font;
import net.rim.device.api.ui.Graphics;
import net.rim.device.api.ui.Manager;
import net.rim.device.api.ui.component.BasicEditField;
import net.rim.device.api.ui.text.TextFilter;

public class BitmapEditField extends Manager {

    Bitmap background;
    BasicEditField editField;
    int offsetX;
    int offsetY;

    public BitmapEditField(Bitmap background, String label, String text) {
        super(NON_FOCUSABLE);
        this.background = background;
        
        editField = new BasicEditField(label, text);
        add(editField);
    }

    public void setOffsets(int x, int y) {
        offsetX = x;
        offsetY = y;
    }

    public void setText(String text) {
        editField.setText(text);
    }
    
    public String getText() {
        return editField.getText();
      }
    
    public void setFont(Font font) {
        editField.setFont(font);
    }
    
    public void setFilter(TextFilter filter) {
        editField.setFilter(filter);
    }
    
    public int getPreferredWidth() {
        return background.getWidth();
    }

    public int getPreferredHeight() {
        return background.getHeight();
    }
    
    public void setBitmap(Bitmap background) {
    	this.background = background;
    }

    protected void sublayout(int width, int height) {
        setPositionChild(editField, offsetX, offsetY);
        layoutChild(editField, getPreferredWidth(), getPreferredHeight());
        
        setExtent(getPreferredWidth(), getPreferredHeight());
    }

    protected void paintBackground(Graphics g) {

*******I want to do something here so that it will be in middle of the screen.

9700.png

        g.drawBitmap(0, 0, background.getWidth(), background.getHeight(), background, 0, 0);
    }
}

 This is custom edit field.

 

package mypackage;

import net.rim.device.api.system.Bitmap;
import net.rim.device.api.ui.Color;
import net.rim.device.api.ui.container.MainScreen;
import net.rim.device.api.ui.decor.Background;
import net.rim.device.api.ui.decor.BackgroundFactory;

public class SearchEditField extends MainScreen {
	
	SearchEditField(){
		
		 Background bg = BackgroundFactory.createSolidBackground(Color.GREEN);

		 MyHeaderLabel header=new MyHeaderLabel();
			header.setText("Search by");
			header.setBackground(bg);
			setBanner(header);
			Bitmap bmp =Bitmap.getBitmapResource("search_bar_portrait_480X800.png");
			BitmapEditField images=new BitmapEditField(bmp, null, null);
			//images.setMargin(150,0,0,0);
			add(images);
		
	}

}

 

Please use plain text.
Developer
arkadyz
Posts: 2,268
Registered: ‎07-08-2009
My Device: various
My Carrier: various

Re: How to make scroll able custom round edit field

Take a look at the following knowledge base article:

Scrollable one-line text input field

The comments to the article contain ideas on adding the border.

 

Good luck!

----------------------------------------------------------
please click 'Accept Solution' on posts that provide the solution to the question you've posted. Don't say "Thanks", press 'Like' button instead!
Please use plain text.