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
New Contributor
Posts: 4
Registered: ‎10-20-2011
My Device: Blackberry Storm
My Carrier: Developer

reset/refresh GridFieldManagers Blackberry

I'm working on an application for the blackberry storm. I use GridFieldManagers to place the menu. If the display landscape then use

gridFieldManager = new GridFieldManagers (2, USE_ALL_HEIGHT); 

but if display potrait then use

gridFieldManager = new GridFieldManagers (4, USE_ALL_HEIGHT); 

I had trouble in resetting the GridFieldManagers. I've been using gridFieldManager. invalidate (), apparently to no avail. is there another solution?

 

thanks.

BlackBerry Development Advisor
Posts: 15,070
Registered: ‎07-09-2008
My Device: BlackBerry Passport
My Carrier: Bell

Re: reset/refresh GridFieldManagers Blackberry

Are you trying to change your manager when the orientation changes?  How are you detecting the orientation change?  What does your GridFieldManagers constructor do?  Can you post a larger code sample?

Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
New Contributor
Posts: 4
Registered: ‎10-20-2011
My Device: Blackberry Storm
My Carrier: Developer

Re: reset/refresh GridFieldManagers Blackberry

[ Edited ]

here my code

import net.rim.device.api.system.Application;
import net.rim.device.api.system.DeviceInfo;
import net.rim.device.api.system.Display;
import net.rim.device.api.system.EncodedImage;
import net.rim.device.api.ui.Field;
import net.rim.device.api.ui.FieldChangeListener;
import net.rim.device.api.ui.Graphics;
import net.rim.device.api.ui.Manager;
import net.rim.device.api.ui.MenuItem;
import net.rim.device.api.ui.UiApplication;
import net.rim.device.api.ui.component.Dialog;
import net.rim.device.api.ui.component.Menu;
import net.rim.device.api.ui.container.MainScreen;
import net.rim.device.api.ui.container.VerticalFieldManager;
import com.blackberry.toolkit.ui.resizeImage;
import com.blackberry.toolkit.ui.component.BitmapButtonField;

public class Test extends MainScreen
{
	resizeImage rs;
	
	private VerticalFieldManager mainManager;
    private VerticalFieldManager subManager;    
    
    private EncodedImage bt1h;
    private EncodedImage ibt1h;
    private EncodedImage bt2h ;
    private EncodedImage ibt2h;
    private EncodedImage bt3h;
    private EncodedImage ibt3h;
    private EncodedImage bt4h ;
    private EncodedImage ibt4h;
    private EncodedImage bt5h;
    private EncodedImage ibt5h;
    private EncodedImage bt6h ;
    private EncodedImage ibt6h;
    private EncodedImage bt7h;
    private EncodedImage ibt7h;
    private EncodedImage bt8h ;
    private EncodedImage ibt8h;
    
    private EncodedImage bt1k;
    private EncodedImage ibt1k;
    private EncodedImage bt2k ;
    private EncodedImage ibt2k;
    private EncodedImage bt3k;
    private EncodedImage ibt3k;
    private EncodedImage bt4k ;
    private EncodedImage ibt4k;
    private EncodedImage bt5k;
    private EncodedImage ibt5k;
    private EncodedImage bt6k ;
    private EncodedImage ibt6k;
    private EncodedImage bt7k;
    private EncodedImage ibt7k;
    private EncodedImage bt8k ;
    private EncodedImage ibt8k;       
    
    private EncodedImage imagebackround;   
    private EncodedImage images;
    
    public static String versions = "";
    public static String Versionss = "";

    String msg = "0";
    
	GridFieldManagers gridFieldManager;
	
    BitmapButtonField b1 ;
    BitmapButtonField b2 ;
    BitmapButtonField b3 ;
    BitmapButtonField c1 ;
    BitmapButtonField c2 ;
    BitmapButtonField c3 ;
    BitmapButtonField d1 ;
    BitmapButtonField d2 ;   

	
    public Test() {    	
    	
    	super(NO_VERTICAL_SCROLL);
    	
    	InitialbuttonMenu();  	    
        gridFieldBackground();      
       
        mainManager = new VerticalFieldManager(
                          Manager.NO_VERTICAL_SCROLL | 
                          Manager.NO_VERTICAL_SCROLLBAR )
        {            
            public void paint(Graphics graphics)
            {            	          
             graphics.clear();            
             graphics.drawBitmap(0, 0, Display.getWidth(), Display.getHeight(), images.getBitmap(), 0, 0);               
             super.paint(graphics); 
            }            
        };
        
        
        //this manger is used for adding the componentes
        subManager = new VerticalFieldManager(
                         Manager.NO_HORIZONTAL_SCROLL |  
                         Manager.NO_HORIZONTAL_SCROLLBAR )
        {
            public void sublayout(int maxWidth, int maxHeight)
            {           	               
                switch (Display.getOrientation()) {
                case Display.ORIENTATION_LANDSCAPE:
                    UiApplication.getUiApplication().invokeLater(new Runnable()
                    {
                        public void run()
                        {                	                         	 	    
                            gridFieldBackground();  
                            InitialbuttonMenu();
                            mainManager.invalidate();                           
                        }
                    });                   

                    break;
                case Display.ORIENTATION_PORTRAIT:               
                	UiApplication.getUiApplication().invokeLater(new Runnable()
                    {
                        public void run()
                        {                     	    
                            gridFieldBackground();  
                            InitialbuttonMenu();
                            mainManager.invalidate();  
                        	                           
                          }
                   });                	
                    break;
                }
                
                super.sublayout(Display.getWidth(), Display.getHeight());
                setExtent(Display.getWidth(), Display.getHeight());
            }
        };
        
        
        gridFieldMenu();   
        //subManager.add(gridFieldManager);
        mainManager.add(subManager);
        this.add(mainManager);         
       
       
    }       
   
    
    /*--------------------------initialisasi button menu-----------------------------*/ 
    
    public void InitialbuttonMenu(){    	   	
    	if (Display.getWidth() == 480 && Display.getHeight() == 360)
        {
        bt1h = EncodedImage.getEncodedImageResource("480x360-index_05h.png");
        ibt1h  =  rs.resizeImages(bt1h, 120, 135);
        bt2h = EncodedImage.getEncodedImageResource("480x360-index_06h.png");
         ibt2h  =  rs.resizeImages(bt2h, 120, 135);
         bt3h = EncodedImage.getEncodedImageResource("480x360-index_07h.png");
         ibt3h  =  rs.resizeImages(bt3h, 120, 135);
         bt4h = EncodedImage.getEncodedImageResource("480x360-index_08h.png");
         ibt4h  =  rs.resizeImages(bt4h, 120, 135);
         bt5h = EncodedImage.getEncodedImageResource("480x360-index_09h.png");
         ibt5h  =  rs.resizeImages(bt5h, 120, 135);
         bt6h = EncodedImage.getEncodedImageResource("480x360-index_10h.png");
         ibt6h  =  rs.resizeImages(bt6h, 120, 135);
         bt7h = EncodedImage.getEncodedImageResource("480x360-index_11h.png");
         ibt7h  =  rs.resizeImages(bt7h, 120, 135);
         bt8h = EncodedImage.getEncodedImageResource("480x360-index_12h.png");
         ibt8h  =  rs.resizeImages(bt8h, 120, 135);
         
         bt1k = EncodedImage.getEncodedImageResource("480x360-index_05k.png");
         ibt1k  =  rs.resizeImages(bt1k, 120, 135);
         bt2k = EncodedImage.getEncodedImageResource("480x360-index_06k.png");
         ibt2k  =  rs.resizeImages(bt2k, 120, 135);
         bt3k = EncodedImage.getEncodedImageResource("480x360-index_07k.png");
         ibt3k  =  rs.resizeImages(bt3k, 120, 135);
         bt4k = EncodedImage.getEncodedImageResource("480x360-index_08k.png");
         ibt4k  =  rs.resizeImages(bt4k, 120, 135);
         bt5k = EncodedImage.getEncodedImageResource("480x360-index_09k.png");
         ibt5k  =  rs.resizeImages(bt5k, 120, 135);
         bt6k = EncodedImage.getEncodedImageResource("480x360-index_10k.png");
         ibt6k  =  rs.resizeImages(bt6k, 120, 135);
         bt7k = EncodedImage.getEncodedImageResource("480x360-index_11k.png");
         ibt7k  =  rs.resizeImages(bt7k, 120, 135);
         bt8k = EncodedImage.getEncodedImageResource("480x360-index_12k.png");
         ibt8k  =  rs.resizeImages(bt8k, 120, 135);
        }
        else if (Display.getWidth() == 320 && Display.getHeight() == 240)
        {
       	 bt1h = EncodedImage.getEncodedImageResource("480x360-index_05h.png");
             ibt1h  =  rs.resizeImages(bt1h, 80, 89);
             bt2h = EncodedImage.getEncodedImageResource("480x360-index_06h.png");
             ibt2h  =  rs.resizeImages(bt2h, 80, 89);
             bt3h = EncodedImage.getEncodedImageResource("480x360-index_07h.png");
             ibt3h  =  rs.resizeImages(bt3h, 80, 89);
             bt4h = EncodedImage.getEncodedImageResource("480x360-index_08h.png");
             ibt4h  =  rs.resizeImages(bt4h, 80, 89);
             bt5h = EncodedImage.getEncodedImageResource("480x360-index_09h.png");
             ibt5h  =  rs.resizeImages(bt5h, 80, 90);
             bt6h = EncodedImage.getEncodedImageResource("480x360-index_10h.png");
             ibt6h  =  rs.resizeImages(bt6h, 80, 90);
             bt7h = EncodedImage.getEncodedImageResource("480x360-index_11h.png");
             ibt7h  =  rs.resizeImages(bt7h, 80, 90);
             bt8h = EncodedImage.getEncodedImageResource("480x360-index_12h.png");
             ibt8h  =  rs.resizeImages(bt8h, 80, 90);
             
             bt1k = EncodedImage.getEncodedImageResource("480x360-index_05k.png");
             ibt1k  =  rs.resizeImages(bt1k, 80, 89);
             bt2k = EncodedImage.getEncodedImageResource("480x360-index_06k.png");
             ibt2k  =  rs.resizeImages(bt2k, 80, 89);
             bt3k = EncodedImage.getEncodedImageResource("480x360-index_07k.png");
             ibt3k  =  rs.resizeImages(bt3k, 80, 89);
             bt4k = EncodedImage.getEncodedImageResource("480x360-index_08k.png");
             ibt4k  =  rs.resizeImages(bt4k, 80, 89);
             bt5k = EncodedImage.getEncodedImageResource("480x360-index_09k.png");
             ibt5k  =  rs.resizeImages(bt5k, 80, 90);
             bt6k = EncodedImage.getEncodedImageResource("480x360-index_10k.png");
             ibt6k  =  rs.resizeImages(bt6k, 80, 90);
             bt7k = EncodedImage.getEncodedImageResource("480x360-index_11k.png");
             ibt7k  =  rs.resizeImages(bt7k, 80, 90);
             bt8k = EncodedImage.getEncodedImageResource("480x360-index_12k.png");
             ibt8k  =  rs.resizeImages(bt8k, 80, 90);
            }
        else if (Display.getWidth() == 360 && Display.getHeight() == 400)
        {
       	     bt1h = EncodedImage.getEncodedImageResource("480x360-index_05h.png");
             ibt1h  =  rs.resizeImages(bt1h, 90, 149);
             bt2h = EncodedImage.getEncodedImageResource("480x360-index_06h.png");
             ibt2h  =  rs.resizeImages(bt2h, 90, 149);
             bt3h = EncodedImage.getEncodedImageResource("480x360-index_07h.png");
             ibt3h  =  rs.resizeImages(bt3h, 90, 149);
             bt4h = EncodedImage.getEncodedImageResource("480x360-index_08h.png");
             ibt4h  =  rs.resizeImages(bt4h, 90, 149);
             bt5h = EncodedImage.getEncodedImageResource("480x360-index_09h.png");
             ibt5h  =  rs.resizeImages(bt5h, 90, 150);
             bt6h = EncodedImage.getEncodedImageResource("480x360-index_10h.png");
             ibt6h  =  rs.resizeImages(bt6h, 90, 150);
             bt7h = EncodedImage.getEncodedImageResource("480x360-index_11h.png");
             ibt7h  =  rs.resizeImages(bt7h, 90, 150);
             bt8h = EncodedImage.getEncodedImageResource("480x360-index_12h.png");
             ibt8h  =  rs.resizeImages(bt8h, 90, 150);
             
             bt1k = EncodedImage.getEncodedImageResource("480x360-index_05k.png");
             ibt1k  =  rs.resizeImages(bt1k, 90, 149);
             bt2k = EncodedImage.getEncodedImageResource("480x360-index_06k.png");
             ibt2k  =  rs.resizeImages(bt2k, 90, 149);
             bt3k = EncodedImage.getEncodedImageResource("480x360-index_07k.png");
             ibt3k  =  rs.resizeImages(bt3k, 90, 149);
             bt4k = EncodedImage.getEncodedImageResource("480x360-index_08k.png");
             ibt4k  =  rs.resizeImages(bt4k, 90, 149);
             bt5k = EncodedImage.getEncodedImageResource("480x360-index_09k.png");
             ibt5k  =  rs.resizeImages(bt5k, 90, 150);
             bt6k = EncodedImage.getEncodedImageResource("480x360-index_10k.png");
             ibt6k  =  rs.resizeImages(bt6k, 90, 150);
             bt7k = EncodedImage.getEncodedImageResource("480x360-index_11k.png");
             ibt7k  =  rs.resizeImages(bt7k, 90, 150);
             bt8k = EncodedImage.getEncodedImageResource("480x360-index_12k.png");
             ibt8k  =  rs.resizeImages(bt8k, 90, 150);
            }
        else if (Display.getWidth() == 480 && Display.getHeight() == 320)
        {
       	     bt1h = EncodedImage.getEncodedImageResource("480x360-index_05h.png");
             ibt1h  =  rs.resizeImages(bt1h, 120,120);
             bt2h = EncodedImage.getEncodedImageResource("480x360-index_06h.png");
             ibt2h  =  rs.resizeImages(bt2h, 120,120);
             bt3h = EncodedImage.getEncodedImageResource("480x360-index_07h.png");
             ibt3h  =  rs.resizeImages(bt3h, 120,120);
             bt4h = EncodedImage.getEncodedImageResource("480x360-index_08h.png");
             ibt4h  =  rs.resizeImages(bt4h, 120,120);
             bt5h = EncodedImage.getEncodedImageResource("480x360-index_09h.png");
             ibt5h  =  rs.resizeImages(bt5h, 120,120);
             bt6h = EncodedImage.getEncodedImageResource("480x360-index_10h.png");
             ibt6h  =  rs.resizeImages(bt6h, 120,120);
             bt7h = EncodedImage.getEncodedImageResource("480x360-index_11h.png");
             ibt7h  =  rs.resizeImages(bt7h, 120,120);
             bt8h = EncodedImage.getEncodedImageResource("480x360-index_12h.png");
             
             ibt8h  =  rs.resizeImages(bt8h, 120,120);
             bt1k = EncodedImage.getEncodedImageResource("480x360-index_05k.png");
             ibt1k  =  rs.resizeImages(bt1k, 120,120);
             bt2k = EncodedImage.getEncodedImageResource("480x360-index_06k.png");
             ibt2k  =  rs.resizeImages(bt2k, 120,120);
             bt3k = EncodedImage.getEncodedImageResource("480x360-index_07k.png");
             ibt3k  =  rs.resizeImages(bt3k, 120,120);
             bt4k = EncodedImage.getEncodedImageResource("480x360-index_08k.png");
             ibt4k  =  rs.resizeImages(bt4k, 120,120);
             bt5k = EncodedImage.getEncodedImageResource("480x360-index_09k.png");
             ibt5k  =  rs.resizeImages(bt5k,120,120);
             bt6k = EncodedImage.getEncodedImageResource("480x360-index_10k.png");
             ibt6k  =  rs.resizeImages(bt6k, 120,120);
             bt7k = EncodedImage.getEncodedImageResource("480x360-index_11k.png");
             ibt7k  =  rs.resizeImages(bt7k, 120,120);
             bt8k = EncodedImage.getEncodedImageResource("480x360-index_12k.png");
             ibt8k  =  rs.resizeImages(bt8k, 120,120);
            }
        else if (Display.getWidth() == 360 && Display.getHeight() == 480)
        {
       	     bt1h = EncodedImage.getEncodedImageResource("00-index_03h.png");
             ibt1h  =  rs.resizeImages(bt1h, 180,90);
             bt2h = EncodedImage.getEncodedImageResource("00-index_04h.png");
             ibt2h  =  rs.resizeImages(bt2h, 180,90);
             bt3h = EncodedImage.getEncodedImageResource("00-index_05h.png");
             ibt3h  =  rs.resizeImages(bt3h, 180, 95);
             bt4h = EncodedImage.getEncodedImageResource("00-index_06h.png");
             ibt4h  =  rs.resizeImages(bt4h, 180, 95);
             bt5h = EncodedImage.getEncodedImageResource("00-index_07h.png");
             ibt5h  =  rs.resizeImages(bt5h, 180, 92);
             bt6h = EncodedImage.getEncodedImageResource("00-index_08h.png");
             ibt6h  =  rs.resizeImages(bt6h, 180, 92);
             bt7h = EncodedImage.getEncodedImageResource("00-index_09h.png");
             ibt7h  =  rs.resizeImages(bt7h, 180, 94);
             bt8h = EncodedImage.getEncodedImageResource("00-index_10h.png");
             ibt8h  =  rs.resizeImages(bt8h, 180, 94);
             
             bt1k = EncodedImage.getEncodedImageResource("00-index_03k.png");
             ibt1k  =  rs.resizeImages(bt1k, 180,90);
             bt2k = EncodedImage.getEncodedImageResource("00-index_04k.png");
             ibt2k  =  rs.resizeImages(bt2k, 180,90);
             bt3k = EncodedImage.getEncodedImageResource("00-index_05k.png");
             ibt3k  =  rs.resizeImages(bt3k, 180, 95);
             bt4k = EncodedImage.getEncodedImageResource("00-index_06k.png");
             ibt4k  =  rs.resizeImages(bt4k, 180, 95);
             bt5k = EncodedImage.getEncodedImageResource("00-index_07k.png");
             ibt5k  =  rs.resizeImages(bt5k, 180, 92);
             bt6k = EncodedImage.getEncodedImageResource("00-index_08k.png");
             ibt6k  =  rs.resizeImages(bt6k, 180, 92);
             bt7k = EncodedImage.getEncodedImageResource("00-index_09k.png");
             ibt7k  =  rs.resizeImages(bt7k, 180, 94);
             bt8k = EncodedImage.getEncodedImageResource("00-index_10k.png");
             ibt8k  =  rs.resizeImages(bt8k, 180, 94);
            }
        else if (Display.getWidth() == 640 && Display.getHeight() == 480)
        {
       	     bt1h = EncodedImage.getEncodedImageResource("480x360-index_05h.png");
             ibt1h  =  rs.resizeImages(bt1h, 160, 179);
             bt2h = EncodedImage.getEncodedImageResource("480x360-index_06h.png");
             ibt2h  =  rs.resizeImages(bt2h, 160, 179);
             bt3h = EncodedImage.getEncodedImageResource("480x360-index_07h.png");
             ibt3h  =  rs.resizeImages(bt3h, 160, 179);
             bt4h = EncodedImage.getEncodedImageResource("480x360-index_08h.png");
             ibt4h  =  rs.resizeImages(bt4h, 160, 179);
             bt5h = EncodedImage.getEncodedImageResource("480x360-index_09h.png");
             ibt5h  =  rs.resizeImages(bt5h, 160, 180);
             bt6h = EncodedImage.getEncodedImageResource("480x360-index_10h.png");
             ibt6h  =  rs.resizeImages(bt6h, 160, 180);
             bt7h = EncodedImage.getEncodedImageResource("480x360-index_11h.png");
             ibt7h  =  rs.resizeImages(bt7h, 160, 180);
             bt8h = EncodedImage.getEncodedImageResource("480x360-index_12h.png");
             ibt8h  =  rs.resizeImages(bt8h, 160, 180);
             
             bt1k = EncodedImage.getEncodedImageResource("480x360-index_05k.png");
             ibt1k  =  rs.resizeImages(bt1k, 160, 179);
             bt2k = EncodedImage.getEncodedImageResource("480x360-index_06k.png");
             ibt2k  =  rs.resizeImages(bt2k, 160, 179);
             bt3k = EncodedImage.getEncodedImageResource("480x360-index_07k.png");
             ibt3k  =  rs.resizeImages(bt3k, 160, 179);
             bt4k = EncodedImage.getEncodedImageResource("480x360-index_08k.png");
             ibt4k  =  rs.resizeImages(bt4k, 160, 179);
             bt5k = EncodedImage.getEncodedImageResource("480x360-index_09k.png");
             ibt5k  =  rs.resizeImages(bt5k, 160, 180);
             bt6k = EncodedImage.getEncodedImageResource("480x360-index_10k.png");
             ibt6k  =  rs.resizeImages(bt6k, 160, 180);
             bt7k = EncodedImage.getEncodedImageResource("480x360-index_11k.png");
             ibt7k  =  rs.resizeImages(bt7k, 160, 180);
             bt8k = EncodedImage.getEncodedImageResource("480x360-index_12k.png");
             ibt8k  =  rs.resizeImages(bt8k, 160, 180);
            }
        else if (Display.getWidth() == 360 && Display.getHeight() == 248)
        {
       	 bt1h = EncodedImage.getEncodedImageResource("480x360-index_05h.png");
             ibt1h  =  rs.resizeImages(bt1h, 90, 93);
             bt2h = EncodedImage.getEncodedImageResource("480x360-index_06h.png");
             ibt2h  =  rs.resizeImages(bt2h, 90, 93);
             bt3h = EncodedImage.getEncodedImageResource("480x360-index_07h.png");
             ibt3h  =  rs.resizeImages(bt3h, 90, 93);
             bt4h = EncodedImage.getEncodedImageResource("480x360-index_08h.png");
             ibt4h  =  rs.resizeImages(bt4h, 90, 93);
             bt5h = EncodedImage.getEncodedImageResource("480x360-index_09h.png");
             ibt5h  =  rs.resizeImages(bt5h, 90, 93);
             bt6h = EncodedImage.getEncodedImageResource("480x360-index_10h.png");
             ibt6h  =  rs.resizeImages(bt6h, 90, 93);
             bt7h = EncodedImage.getEncodedImageResource("480x360-index_11h.png");
             ibt7h  =  rs.resizeImages(bt7h, 90, 93);
             bt8h = EncodedImage.getEncodedImageResource("480x360-index_12h.png");
             ibt8h  =  rs.resizeImages(bt8h, 90, 93);
             
             bt1k = EncodedImage.getEncodedImageResource("480x360-index_05k.png");
             ibt1k  =  rs.resizeImages(bt1k, 90, 93);
             bt2k = EncodedImage.getEncodedImageResource("480x360-index_06k.png");
             ibt2k  =  rs.resizeImages(bt2k, 90, 93);
             bt3k = EncodedImage.getEncodedImageResource("480x360-index_07k.png");
             ibt3k  =  rs.resizeImages(bt3k, 90, 93);
             bt4k = EncodedImage.getEncodedImageResource("480x360-index_08k.png");
             ibt4k  =  rs.resizeImages(bt4k, 90, 93);
             bt5k = EncodedImage.getEncodedImageResource("480x360-index_09k.png");
             ibt5k  =  rs.resizeImages(bt5k, 90, 93);
             bt6k = EncodedImage.getEncodedImageResource("480x360-index_10k.png");
             ibt6k  =  rs.resizeImages(bt6k, 90, 93);
             bt7k = EncodedImage.getEncodedImageResource("480x360-index_11k.png");
             ibt7k  =  rs.resizeImages(bt7k, 90, 93);
             bt8k = EncodedImage.getEncodedImageResource("480x360-index_12k.png");
             ibt8k  =  rs.resizeImages(bt8k, 90, 93);
            }    	    	 	
    }
 
    /*-------------------------------------------------------------------------------*/
    
    public boolean onClose() {
		Application.getApplication().requestBackground();
		return false;    	
	}    
    
    private void gridFieldBackground() {  
    	 if (Display.getWidth() == 360 && Display.getHeight() == 480) {
     	  	imagebackround = EncodedImage.getEncodedImageResource("00-index.png");
     	  }else {
         	imagebackround = EncodedImage.getEncodedImageResource("480x360-index.png");
     	  }
     	  
     	  if (DeviceInfo.getDeviceName() == "9500" || DeviceInfo.getDeviceName() == "9520") {
     	        images  =  rs.resizeImages(imagebackround, Display.getWidth(), Display.getHeight());
             }else {
             	images  =  rs.resizeImages(imagebackround, Display.getWidth(), Display.getHeight());
             }
    }    
       
    private void gridFieldMenu() {    	    	    	
    	if (Display.getWidth() == 360 && Display.getHeight() == 480){
		 gridFieldManager = new GridFieldManagers(2,USE_ALL_HEIGHT);
		  b1 =  new BitmapButtonField("1",ibt1h.getBitmap(), ibt1k.getBitmap());
		  b2 =  new BitmapButtonField("2",ibt2h.getBitmap(), ibt2k.getBitmap());
		  b3 =  new BitmapButtonField("3",ibt3h.getBitmap(), ibt3k.getBitmap());
		  c1 =  new BitmapButtonField("4",ibt4h.getBitmap(), ibt4k.getBitmap());
		  c2 =  new BitmapButtonField("5",ibt5h.getBitmap(), ibt5k.getBitmap());
		  c3 =  new BitmapButtonField("6",ibt6h.getBitmap(), ibt6k.getBitmap());
		  d1 =  new BitmapButtonField("7",ibt7h.getBitmap(), ibt7k.getBitmap());
		  d2 =  new BitmapButtonField("8",ibt8h.getBitmap(), ibt8k.getBitmap());
        }else{
         gridFieldManager = new GridFieldManagers(4,USE_ALL_HEIGHT);
          b1 =  new BitmapButtonField("1",ibt1h.getBitmap(), ibt1k.getBitmap());
          b2 =  new BitmapButtonField("2",ibt2h.getBitmap(), ibt2k.getBitmap());
          b3 =  new BitmapButtonField("3",ibt3h.getBitmap(), ibt3k.getBitmap());
          c1 =  new BitmapButtonField("4",ibt4h.getBitmap(), ibt4k.getBitmap());
          c2 =  new BitmapButtonField("5",ibt5h.getBitmap(), ibt5k.getBitmap());
          c3 =  new BitmapButtonField("6",ibt6h.getBitmap(), ibt6k.getBitmap());
          d1 =  new BitmapButtonField("7",ibt7h.getBitmap(), ibt7k.getBitmap());
          d2 =  new BitmapButtonField("8",ibt8h.getBitmap(), ibt8k.getBitmap());
        }        
        
        b1.setChangeListener( new FieldChangeListener( ) {
            public void fieldChanged( Field field, int context ) {
            	
            }
        } );
        b2.setChangeListener( new FieldChangeListener( ) {
            public void fieldChanged( Field field, int context ) {
           	
            }
        } );
        b3.setChangeListener( new FieldChangeListener( ) {
            public void fieldChanged( Field field, int context ) {
           	 		
            }
        } );
        c1.setChangeListener( new FieldChangeListener( ) {
            public void fieldChanged( Field field, int context ) {
            }
        } );
        c2.setChangeListener( new FieldChangeListener( ) {
            public void fieldChanged( Field field, int context ) {
            }
        } );
       
        c3.setChangeListener( new FieldChangeListener( ) {
            public void fieldChanged( Field field, int context ) {
            }
        } );
        d1.setChangeListener( new FieldChangeListener( ) {
            public void fieldChanged( Field field, int context ) {
            }
        } );
        
        d2.setChangeListener( new FieldChangeListener( ) {
            public void fieldChanged( Field field, int context ) {           
           }
        } );
    
        gridFieldManager.add(b1);        
        gridFieldManager.add(b2);  
        gridFieldManager.add(b3);
        gridFieldManager.add(c1);         
        gridFieldManager.add(c2);
        gridFieldManager.add(c3);         
        gridFieldManager.add(d1);
        gridFieldManager.add(d2);
        
       if (Display.getWidth() == 480 && Display.getHeight() == 360){
    	   gridFieldManager.setMargin(65, 0, 0, 0);
       }else if (Display.getWidth() == 320 && Display.getHeight() == 240){
    	   gridFieldManager.setMargin(43, 0, 0, 0);
       }else if (Display.getWidth() == 360 && Display.getHeight() == 400){
    	   gridFieldManager.setMargin(72, 0, 0, 0);
       }else if (Display.getWidth() == 480 && Display.getHeight() == 320){
    	   gridFieldManager.setMargin(57, 0, 0, 0);
       }else if (Display.getWidth() == 360 && Display.getHeight() == 480){        	
    	   gridFieldManager.setMargin(76, 0, 0, 0);
       }else if (Display.getWidth() == 640 && Display.getHeight() == 480){        	
    	   gridFieldManager.setMargin(87, 0, 0, 0);
       }else if (Display.getWidth() == 360 && Display.getHeight() == 248){        	
    	   gridFieldManager.setMargin(44, 0, 0, 0);
       }
    }       
      
	public void refreshMenuIcon() {    	
		subManager.delete(gridFieldManager);
                  
    	InitialbuttonMenu();
		gridFieldMenu();
        
		subManager.add( gridFieldManager );
        mainManager.add(subManager);
        this.add(mainManager);
	}

	public void resetMainUI() {		
		
		subManager.delete(gridFieldManager);
				
		InitialbuttonMenu();  	    
        gridFieldBackground();
        gridFieldMenu();
 	
       subManager.add( gridFieldManager );
       mainManager.add(subManager);
       this.add(mainManager);  
        
	}
}

 

I want to reset/refresh gridfieldmanager when display landscape or portrait.  Thanks

New Contributor
Posts: 4
Registered: ‎10-20-2011
My Device: Blackberry Storm
My Carrier: Developer

Re: reset/refresh GridFieldManagers Blackberry

I've posted the code
BlackBerry Development Advisor
Posts: 15,070
Registered: ‎07-09-2008
My Device: BlackBerry Passport
My Carrier: Bell

Re: reset/refresh GridFieldManagers Blackberry

Within your sublayout I see that you are changing your images, but I don't see any calls to change the GridFieldManager.  Is this what you are trying to do?  Can you outline what you are trying to accomplish?

Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
New Contributor
Posts: 4
Registered: ‎10-20-2011
My Device: Blackberry Storm
My Carrier: Developer

Re: reset/refresh GridFieldManagers Blackberry

[ Edited ]

here the method to change the layout when portrait or landscape.

 

public void sublayout(int maxWidth, int maxHeight)
            {           	               
                switch (Display.getOrientation()) {
                case Display.ORIENTATION_LANDSCAPE:
                    UiApplication.getUiApplication().invokeLater(new Runnable()
                    {
                        public void run()
                        {                	                         	 	    
                            gridFieldBackground();  
                            InitialbuttonMenu();
                            mainManager.invalidate();                           
                        }
                    });                   

                    break;
                case Display.ORIENTATION_PORTRAIT:               
                	UiApplication.getUiApplication().invokeLater(new Runnable()
                    {
                        public void run()
                        {                     	    
                            gridFieldBackground();  
                            InitialbuttonMenu();
                            mainManager.invalidate();  
                        	                           
                          }
                   });                	
                    break;
                }
                
                super.sublayout(Display.getWidth(), Display.getHeight());
                setExtent(Display.getWidth(), Display.getHeight());
            }

  to gridfield manager I created in this method

gridFieldMenu()

 

so to add it in the layout using this code

 

subManager.delete(gridFieldManager);
InitialbuttonMenu();  	    
gridFieldBackground();
gridFieldMenu();
 	
subManager.add( gridFieldManager );
mainManager.add(subManager);
this.add(mainManager);

 

but if the code is inserted in a thread, he will do so continuously. is there another solution?