Search code examples
blackberryvertical-scrollingbrowserfield

Blackberry scoll only browserfield, not entire app-layout


I have a verticalfieldmanager with buttons and below that a browserfield. The problem is that when I scroll vertically in the browserfield the whole layout of the app scrolls with it(!).. I've been looking like a mad man for a sollution but haven't found anything yet. I tried disabling vertical scroll in the app but this only results in not being able to scroll the browserfield/homepage.

Any suggestions?

Thanks


Solution

  • Hope this code helps you: try this;

    public class NewsBrowserScreen extends MainScreen implements FieldChangeListener
    {   
    String url="http://www.google.com/news/";
    VerticalFieldManager vertical;  
    BrowserField browserField;
    ButtonField click;
    
    public NewsBrowserScreen() 
    {           
        createGUI();
    }
    private void createGUI()    
    {   
        click=new ButtonField("Click",Field.FIELD_HCENTER);
        click.setChangeListener(this);      
        add(click);
    
        vertical=new VerticalFieldManager(VERTICAL_SCROLL|VERTICAL_SCROLLBAR|HORIZONTAL_SCROLL|HORIZONTAL_SCROLLBAR)
        {
            protected void sublayout(int maxWidth, int maxHeight) 
            {
                super.sublayout(Display.getWidth(),250);
                setExtent(Display.getWidth(),250);
            }
        };          
        vertical.setBackground(BackgroundFactory.createSolidBackground(Color.GREEN));
        vertical.setPadding(10, 0, 10, 0);
        add(vertical);      
    }
    
    protected boolean onSavePrompt()
    {       
        return true;
    }
    
    public boolean onMenu(int instance) 
    {
        return true;
    }
    
    public void fieldChanged(Field field, int context)
    {
        if(field==click)
        {
            browserField=new BrowserField();        
            vertical.add(browserField);
            browserField.requestContent(url);
        }
    }   
    }
    

    I Get like this below Image;

    Google News