Search Results

Search found 1 results on 1 pages for 'huffmaster'.

Page 1/1 | 1 

  • How can a link within a WebView load another layout using javascript?

    - by huffmaster
    So I have 2 layout files (main.xml, featured.xml) and both each have a single WebView. When the application starts "main.xml" loads a html file into it's WebView. In this html file I have a link that calls javascript that runs code in the Activity that loaded the html. Once back in this Activity code though I try running setContentView(R.layout.featured) but it just bombs out on me. If I debug it just dies without any real error and if I run it the application just Force closes. Am I going about this correctly or should I be doing something differently? final private int MAIN = 1; final private int FEATURED = 2; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); webview = (WebView) findViewById(R.id.wvMain); webview.getSettings().setJavaScriptEnabled(true); webview.getSettings().setSupportZoom(false); webview.addJavascriptInterface(new EHJavaScriptInterface(), "eh"); webview.loadUrl("file:///android_asset/default.html"); } final class EHJavaScriptInterface { EHJavaScriptInterface() { } public void loadLayout(final String lo) { int i = Integer.parseInt(lo.trim()); switch (i) { /****** THIS IS WHERE I'M BOMBING OUT *********/ case FEATURED: setContentView(R.layout.featured);break; case MAIN: setContentView(R.layout.main);break; } } }

    Read the article

1