My app has 5 tabs and starts with tab 1 selected. Another tabs contains a webview that loads an html file and takes some seconds to display it. Is there any method to improve webview html file loading? For eg tab 3, webview does not start loading until tab is pressed, how to start loading content just when app starts and don’t have to wait user tab selection?
main activity onCreate,
addTab(tab1name, R.drawable.tab_home, tab1.class);
addTab(tab2name, R.drawable.tab_search, webPush2.class);
addTab(tab3name, R.drawable.tab_home, webPush3.class);
addTab(tab4name, R.drawable.tab_search, webPush4.class);
addTab(tab5name, R.drawable.tab_home, webPush5.class);
webPush3 onCreate,
super.onCreate(savedInstanceState);
setContentView(R.layout.webview);
browse3 = (WebView) findViewById(R.id.webview1);
browse3.getSettings().setJavaScriptEnabled(true);
browse3.loadUrl("file:///data/data/" + PACKAGE_NAME + view3 + ".html");
Instead of using tabs, you can simply create a WebView with visibility of GONE. That will keep it so that it’s not shown, and you can start it up loading. If you still want several screens switched based on tabs, you would just setVisibility to VISIBLE on the one one want to show, and set the others to GONE.