If you are using Internet Explorer, please remove blackberry.com from your compatibility view settings.

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
Super Contributor
Achin
Posts: 425
Registered: ‎01-02-2013
My Device: BOLD 9900
My Carrier: sdvsdvsd
Accepted Solution

edit text field and button is not editable when added to Horizontal manager

i have make search layout , when i added the EditField and button to  Horizontal manager, i'm not able to write any thing in the EditField and not able to click on the button

public class MyStorySearch extends MainScreen
{
	
	private VerticalFieldManager mainManager;
    private VerticalFieldManager subManager;
    private Bitmap _backgroundBitmap = Bitmap.getBitmapResource("a.png");       
    private int deviceWidth = Display.getWidth();
    private int deviceHeight = Display.getHeight();
    LabelField lbl;
    ButtonField gobtn= new ButtonField("Go");
    HorizontalFieldManager hfm = new HorizontalFieldManager(Manager.FOCUSABLE|Manager.EDITABLE);
	private Field editfild;
	Bitmap bitmapImage = Bitmap.getBitmapResource("storysearch.png");
	BitmapField fieldDemo;
    
    public MyStorySearch() 
    {
        super(NO_VERTICAL_SCROLL);
        //this manager is used for the static background image
        mainManager = new VerticalFieldManager(
                          Manager.NO_VERTICAL_SCROLL | 
                          Manager.NO_VERTICAL_SCROLLBAR )
        {            
            public void paint(Graphics graphics)
            {
                graphics.clear();
                graphics.drawBitmap(0, 0, deviceWidth,            
                         deviceHeight, _backgroundBitmap, 0, 0);                 
                super.paint(graphics);
            }            
        };
        
        //this manger is used for adding the componentes
        subManager = new VerticalFieldManager(
                         Manager.VERTICAL_SCROLL |  
                         Manager.VERTICAL_SCROLLBAR )
        {
            protected void sublayout(int maxWidth, int maxHeight)
            {
                int displayWidth = deviceWidth;
                int displayHeight = deviceHeight;
 
                super.sublayout( displayWidth, displayHeight);
                setExtent( displayWidth, displayHeight);
            }
        };
                
        //add your component to this subManager       
        lbl = new LabelField("SUNRAYS SEARCH", LabelField.USE_ALL_WIDTH | DrawStyle.HCENTER);
        Font myFont = Font.getDefault().derive(Font.PLAIN, 10, Ui.UNITS_pt);
        lbl.setFont(myFont);
        subManager.add(lbl);
        subManager.add(new SeparatorField());
        
        editfild = new EditField(){
        	protected void layout(int width, int height) {
				setExtent(width*85/100, 30);
			
			};
        };
        editfild.setBorder( BorderFactory.createSimpleBorder( new XYEdges(2, 2, 2, 2),
                new XYEdges(Color.BLACK, Color.BLACK, Color.BLACK, Color.BLACK), Border.STYLE_SOLID));
        editfild.setBackground(BackgroundFactory.createSolidBackground(Color.WHITE));
        
        hfm.add(editfild);
        hfm.add(gobtn);
        
       
        subManager.add(hfm);
        
        //add subManager over the mainManager
        mainManager.add(subManager);
        
        //finally add the mainManager over the screen
        this.add(mainManager);   
    }  
}

 

 

9630-01.png

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

Re: edit text field and button is not editable when added to Horizontal manager

Before we start helping you with further queries, could you please go through the list of previous questions and either

a) mark up any that are solved,

b) or they are not solved, can you indicate this and what you are actually waiting for.

Remember this is a community forum and if you expect answers, then it is appropraite for you to to act as a responsible member of the community.  Leaving questions 'hanging' and not giving feedback does not help the community. 

 

Further information on all of this can be found in the Help link at the top, and I encourage you to read these pages specficially:

http://supportforums.blackberry.com/t5/help/faqpage/faq-category-id/participation#participation

http://supportforums.blackberry.com/t5/help/faqpage/faq-category-id/solutions#solutions

 

Recent Threads from you include the following:

 

http://supportforums.blackberry.com/t5/Java-Development/how-to-center-the-button-on-popup-screen/m-p...

 

http://supportforums.blackberry.com/t5/Java-Development/move-text-from-left-to-right-and-right-to-le...

 

http://supportforums.blackberry.com/t5/Java-Development/add-screen-over-another-screen/m-p/2354365

 

http://supportforums.blackberry.com/t5/Java-Development/save-fonts/td-p/2315605

 

http://supportforums.blackberry.com/t5/Java-Development/navigationMoment-method-to-fast-how-to-slow-...

 

http://supportforums.blackberry.com/t5/Java-Development/regarding-Analytics-Service/td-p/2344957

 

http://supportforums.blackberry.com/t5/Java-Development/how-to-make-search-layout-like-this/m-p/2335...

Please use plain text.
Super Contributor
Achin
Posts: 425
Registered: ‎01-02-2013
My Device: BOLD 9900
My Carrier: sdvsdvsd

Re: edit text field and button is not editable when added to Horizontal manager

ok, i have mark them as solved, now plz could you ans, my question
Please use plain text.
Developer
peter_strange
Posts: 19,601
Registered: ‎07-14-2008
My Device: Not Specified

Re: edit text field and button is not editable when added to Horizontal manager

[ Edited ]

The following code display an EditField and a Button, and I can type in the EditField and click on the button.  It is not perfect, but at least it works.

 

I'm not sure what is wrong with your code.  I suggest you review my code, review your code and investigate the things that are different. 

 

Two areas I would concentrate on your layout and sublayout.  As noted in a previous post, if you need to code a setExtent in a layout then you should really think about creating your own Manager - I have given you links for doing that a  number of times.  And if you expect to use a standard Field and for it to work correctly, you have to use its sublayout.  Here is a link to help you create custom Fields:

http://supportforums.blackberry.com/t5/Java-Development/Create-custom-fields/ta-p/444962 

 

Edit:

 

Thanks for updating those Threads.

 

And sorry.   Forgot to paste in the code....  Here it is now...

 

        EditField editfild = new EditField(){
        	protected void layout(int width, int height) {
        		super.layout(width*85/100, height);
			};
        };
        editfild.setBorder( BorderFactory.createSimpleBorder( new XYEdges(2, 2, 2, 2),
                new XYEdges(Color.BLACK, Color.BLACK, Color.BLACK, Color.BLACK), Border.STYLE_SOLID));
        editfild.setBackground(BackgroundFactory.createSolidBackground(Color.WHITE));
        ButtonField gobtn= new ButtonField("Go") {
        	protected boolean navigationClick(int status, int time){
        		Status.show("button clicked");
        		return true;
        	}
        };
        HorizontalFieldManager hfm = new HorizontalFieldManager();
        hfm.add(editfild);
        hfm.add(gobtn);
        this.add(hfm);

 

 

 

Please use plain text.