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

how to make search layout like this

i want ot make layout for search , i want to display edittext field with a button in one rowi have used horizontal manager to display that in one row but did not display correctly plz 9630.png

public final class MyScreen extends MainScreen
{
	HorizontalFieldManager hrm;
	HorizontalFieldManager hrm2;
	ButtonField gobtn;
    EditField editfild;
    
    public MyScreen()
    {        
        // Set the displayed title of the screen       
        setTitle("search");
    	System.out.println(Display.getWidth());
    	
    	hrm = new HorizontalFieldManager(/*Field.FIELD_RIGHT*/){

    		protected void sublayout(int maxWidth, int maxHeight) {
				// TODO Auto-generated method stub
    			super.sublayout(Display.getWidth()-50,maxHeight);  
    			
			}
    		
    		
    	};
    	hrm2 = new HorizontalFieldManager(Field.FIELD_RIGHT);
    	
    	editfild = new EditField();
        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));
        gobtn = new ButtonField("go",ButtonField.CONSUME_CLICK);
        
        hrm.add(editfild);
        hrm2.add(gobtn);
       
        
        this.add(hrm);
        this.add(hrm2);
        
    }
}

 

help me

Super Contributor
Posts: 425
Registered: ‎01-02-2013
My Device: BOLD 9900
My Carrier: sdvsdvsd

Re: how to make search layout like this

plz solve my issue
Developer
Posts: 206
Registered: ‎02-22-2011
My Device: BB TORCH & 9800
My Carrier: idea

Re: how to make search layout like this

[ Edited ]

You can check the "keywordfilterdemo" sample app (It exists in the samples folder).

Regards
Anil

*****************************************************************************
* Give kudos when you like it
* Mark it as a solution if it fixes your issue
Super Contributor
Posts: 425
Registered: ‎01-02-2013
My Device: BOLD 9900
My Carrier: sdvsdvsd

Re: how to make search layout like this

but i want to make my own search view because i'm searching data from database.and the data is very large.
Developer
Posts: 692
Registered: ‎08-09-2010
My Device: Not Specified

Re: how to make search layout like this

Hi Achin,

 

 Please check below code

 

 

public final class MyScreen extends MainScreen {
	/**
	 * Creates a new MyScreen object
	 */
	HorizontalFieldManager hfm;
	ButtonField b;
	EditField t;

	public MyScreen() {
		// Set the displayed title of the screen
		setTitle("MyTitle");
		hfm = new HorizontalFieldManager();
		b = new ButtonField("Go");
		t = new EditField() {
			protected void layout(int width, int height) {
				setExtent(Display.getWidth() - 50, 60);
			};

		};
		t.setBorder(BorderFactory
				.createSimpleBorder(new XYEdges(2, 2, 2, 2), new XYEdges(
						Color.BLACK, Color.BLACK, Color.BLACK, Color.BLACK),
						Border.STYLE_SOLID));
		t.setBackground(BackgroundFactory.createSolidBackground(Color.WHITE));

		hfm.add(t);
		hfm.add(b);

		add(hfm);

	}
}

 

 

-------------------------------------------------------------------------------

 

feel free to press the like button on the right side to thank the user that helped you.

Highlighted
Super Contributor
Posts: 425
Registered: ‎01-02-2013
My Device: BOLD 9900
My Carrier: sdvsdvsd

Re: how to make search layout like this

every thing works fine but i'm not able to write some text in edit text field and not able to focus on button
Developer
Posts: 285
Registered: ‎08-26-2011
My Device: 9900
My Carrier: Not Specified

Re: how to make search layout like this

I think this will help you. 

 

public final class LoadingScreen extends MainScreen implements FieldChangeListener
{
	private EditField editField;
	public LoadingScreen()
    {        
        createGUI();
    }
	
	private void createGUI()
	{
		HorizontalFieldManager searchHFM = new HorizontalFieldManager(Field.FIELD_HCENTER);
    	
    	editField = new EditField()
    	{
    		protected void layout(int maxWidth, int maxHeight) 
    		{
    			super.layout(Display.getWidth()-100,50);    
    			setExtent(Display.getWidth()-100,50);
			}	
    	};
    	editField.setBorder( BorderFactory.createSimpleBorder( new XYEdges(2, 2, 2, 2),new XYEdges(Color.BLACK, Color.BLACK, Color.BLACK, Color.BLACK), Border.STYLE_SOLID));
    	editField.setBackground(BackgroundFactory.createSolidBackground(Color.WHITE));
        ButtonField goButton = new ButtonField("GO",ButtonField.CONSUME_CLICK|ButtonField.FIELD_RIGHT);
        goButton.setChangeListener(this);
        searchHFM.add(editField);
        searchHFM.add(goButton);
        add(searchHFM);
	}

	public void fieldChanged(Field field, int context) 
	{
		
	}
}

 

=================================================================================
Feel free to click LIKE button if the solution helps you;
--
Regards,

ALI SHAIK.