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
Contributor
Posts: 11
Registered: ‎06-29-2011
My Device: 9800
My Carrier: Vodafone
Accepted Solution

How to reduce size of autoCompletefields?

public class HorizontalScreen extends MainScreen {
	Bitmap backgroundBitmap;
	VerticalFieldManager vfm;
	BasicFilteredList fl1,fl2;
	AutoCompleteField acf1,acf2;
public HorizontalScreen(){
	super(Manager.NO_VERTICAL_SCROLL);
	backgroundBitmap = Bitmap.getBitmapResource("background.png");
	
		vfm=new VerticalFieldManager(USE_ALL_WIDTH|USE_ALL_HEIGHT){
		
		public void paint(Graphics graphics)
        {
			graphics.drawBitmap(0, 0, 360, 480, backgroundBitmap, 0, 0);
			super.paint(graphics);
        }
	};
	add(vfm);
	vfm.add(new LabelField("haijani"));
	vfm.add(new LabelField("haigopi"));
	 fl1 = new BasicFilteredList();
     fl2 = new BasicFilteredList();
     String chs1[]={"10","20","30","40"};
     String chs2[]={"1","2","3","4"};
     
	  fl1.addDataSet(0,chs1,"Temperature",BasicFilteredList.COMPARISON_IGNORE_CASE);
	  fl2.addDataSet(0,chs2,"Pressure",BasicFilteredList.COMPARISON_IGNORE_CASE);
	  //acf1= new AutoCompleteField(fl1,AutoCompleteField.LIST_SHOW_MATCHED_FIELD_VALUE|AutoCompleteField.LIST_DROPDOWN);
	// acf2= new AutoCompleteField(fl2,AutoCompleteField.LIST_SHOW_MATCHED_FIELD_VALUE|AutoCompleteField.LIST_DROPDOWN);	 
	//  fl1.addDataSet(0,days,"days",BasicFilteredList.COMPARISON_IGNORE_CASE);
	 // acf1 = new AutoCompleteField(fl1);
	  acf2 = new AutoCompleteField(fl2,AutoCompleteField.FIELD_LEFT){
		  public int getPreferredWidth()
		    {
		        return 10;
		    }
	  };
	  acf1 = new AutoCompleteField(fl1,AutoCompleteField.FIELD_LEFT){
		  public int getPreferredWidth()
		    {
		        return 10;
		    }
	  };

	  vfm.add(acf2);
	  vfm.add(acf1);

}
  1.  Here in the above code i have implemented verticalFieldManger.
  2. To vfm i have added 2 labelFields and to autoCompleteFields.
  3. My problem is i am unable reduce the width of Two autoCompleteFields.
  4. i have overWritten getPrefferedWidth method .

 



 

 

i have to reduce widths of autoCompleteFields

 

Please reply me

Thanks & Regards
Jani Basha
Developer
Posts: 404
Registered: ‎05-31-2011
My Device: curve
My Carrier: devel

Re: How to reduce size of autoCompletefields?

you can use setExtent
Contributor
Posts: 11
Registered: ‎06-29-2011
My Device: 9800
My Carrier: Vodafone

Re: How to reduce size of autoCompletefields?

thanks for reply

 

where i have to use setExtent method.

 

i know we have to write in

 

sublayout method

but here i am not using sublayout method.

Thanks & Regards
Jani Basha
Highlighted
Developer
Posts: 404
Registered: ‎05-31-2011
My Device: curve
My Carrier: devel

Re: How to reduce size of autoCompletefields?

you must override the layout function ex:
protected void layout(int width, int height) {
setExtent(Display.getWidth(),height);
}
Regular Contributor
Posts: 96
Registered: ‎06-09-2011
My Device: sdk 9800
My Carrier: java development

Re: How to reduce size of autoCompletefields?

just write sublayout method inside ur vertical field manager and keep set extent

 

VerticalFieldManager vfm=new VerticalFieldManager(){

protected void sublayout(int width,int height){

\\ implementation

\\ implementation

 

}

setExtent(--,--) ;//give ur dimensions here

};

Press the Kudos button (star) on the left side to thank and
please mark the Thread as solved if its solved...


Thanks and Regards
Nagarjuna
Contributor
Posts: 11
Registered: ‎06-29-2011
My Device: 9800
My Carrier: Vodafone

Re: How to reduce size of autoCompletefields?

thankyou i have solved the problem.

for others reference iam keeping code here

 

creating button Field with sizes as of our requirement

creating autoCompleteField with sizes as of our requirement

then creating horizontal field manger with sublayout method.

adding above two fields to horizontal field manger.

 

then problem solved

bt=new ButtonField("CLICK",Field.FIELD_HCENTER | ButtonField.CONSUME_CLICK){
        	public int getPreferredWidth(){
          		return 50;
          	}
            public int getPreferredHeight()
    		  {
    			  return 20;
    			  
    		  }
    		  public void layout(int maxWidth,int maxheight){
    			  
    			  super.layout(getPreferredWidth(),getPreferredHeight());
    				setExtent(getPreferredWidth(),getPreferredHeight());
    				
    		  }
        };
acf2 = new AutoCompleteField(fl2,AutoCompleteField.FIELD_LEFT){
		  public int getPreferredWidth()
		    {
		       return 100;
		       
		    }
		  public int getPreferredHeight()
		  {
			  return 70;
			  
		  }
		  public void sublayout(int maxWidth,int maxheight){
			  
			  super.sublayout(getPreferredWidth(),getPreferredHeight());
				setExtent(getPreferredWidth(),getPreferredHeight());
				
		  }
	  };
hfm= new HorizontalFieldManager(USE_ALL_WIDTH|USE_ALL_HEIGHT){
    	     		
             		 public int getPreferredWidth() 
           			{
           				return 300;
           			}
           			public int getPreferredHeight() 
           			{
                                           // fixed height
           				return 40;
           			}
         			protected void sublayout( int maxWidth, int maxHeight )		
         			{
         				
         	    		
         				super.sublayout(getPreferredWidth(),getPreferredHeight());
         				setExtent(getPreferredWidth(),getPreferredHeight());
         				
         			}
                	};
hfm.add(bt);
hfm.add(acf2);

 

 

 

 

 

Thanks & Regards
Jani Basha
Regular Contributor
Posts: 96
Registered: ‎06-09-2011
My Device: sdk 9800
My Carrier: java development

Re: How to reduce size of autoCompletefields?

ohh.....thts great

Press the Kudos button (star) on the left side to thank and
please mark the Thread as solved if its solved...


Thanks and Regards
Nagarjuna
Developer
Posts: 80
Registered: ‎06-06-2011
My Device: bold 9000
My Carrier: airtel

Re: How to reduce size of autoCompletefields?

Thanks a lot 

 

This was really Helpfull

 

Thanks

Krishnan

Contributor
Posts: 46
Registered: ‎07-07-2011
My Device: 9800
My Carrier: BlackBerry

Re: How to reduce size of autoCompletefields?

Mr.Jani Thanks a lot.

This is very very very helpful to me