1

当我尝试下面的代码时,它会阻塞 UI 线程(我认为)它会加载一个空白页面。有人可以告诉我正确的实施方法是什么handleNavigationRequest。我尝试实现它,但是当我尝试运行时,我得到一个handleNavigationRequest必须是接口的错误。

这是代码

class BrowserFieldScreen extends MainScreen 
    {  
        public BrowserFieldScreen()

        {   
            BrowserFieldConfig browserFieldConfig = new BrowserFC();
            BrowserFieldListener browserFieldListener = new BrowserFL();                
            BrowserField browserField = new BrowserField(browserFieldConfig);
            browserField.addListener(browserFieldListener);         
            ProtocolController controller = new ProtocolController(browserField) {
                public void handleNavigationRequest(BrowserFieldRequest request) throws Exception {


                   }
                };
            browserField.getConfig().setProperty(BrowserFieldConfig.CONTROLLER, controller);
            browserField.requestContent("http://meul-online.com");
            super.add(browserField);
        }
4

1 回答 1

4

问题是您正在请求页面但不显示它。

试试这个

    /**
 * Handle navigation requests (e.g., link clicks)
 */
public void handleNavigationRequest(final BrowserFieldRequest request) throws Exception {
    try {
        final InputConnection ic = handleResourceRequest(request);
        UiApplication.getUiApplication().invokeLater(new Runnable() {

            public void run() {
                browserField.setFocus();
                browserField.displayContent(ic, request.getURL());  
            }
        });
    } catch (Exception e) { 
        Log.Error(e, "handleNavigationRequest");
    }

}
于 2011-12-08T08:29:43.673 回答