Question

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

Was it helpful?

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

OTHER TIPS

You can add a VerticalFieldManager to your MainScreen and add your BrowserField to your VerticalFieldManager. You should set style of VerticalFieldManager with VERTICAL_SCROLL | VERTICAL_SCROLLBAR and clear the syle of your MainScreen

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top