android - Fragment webview java script function is not working -


i have dynamically created action bar , tabs. have define class tab fragments below code.

public static class tabfragmentclass extends fragment {     @override public view oncreateview(layoutinflater inflater, viewgroup container,         bundle savedinstancestate) {     // todo auto-generated method stub        try        {            linearlayout=new linearlayout(sactivecontext);            linearlayout.setlayoutparams(new layoutparams(layoutparams.fill_parent,layoutparams.fill_parent));             linearlayout.setorientation(linearlayout.vertical);            customwebview webview=new customwebview(sactivecontext);            framelayout layout=webview.createwebview();            (int = 0; < arraylist.size(); i++) {                if(sactionbar.getselectedtab().getposition()==i)                {                    webview.initwebview(arraylist.get(i));                    mwebviewlist.add(i, webview);                    break;                }            }            linearlayout.addview(layout);            linearlayout.setid(sactionbar.getselectedtab().getposition());            return linearlayout;         }         catch(exception error)         {             system.out.println(error.getmessage());             return null;         }   }    } 

the url local html file having own native java method calls. if select action bar tab first time, working fine. native java method correctly called , callback success. if visiting tab second time, fragment shown, tabs content not re-created. i need functionality of tab content not created each time. facing issue of native method not defined error. native method not called @ all. how can fix issue?

change fragment this,

public static class tabfragmentclass extends fragment {       private static customwebview webview=null;    private static boolean isinitialized=false;  @override public view oncreateview(layoutinflater inflater, viewgroup container,         bundle savedinstancestate) {     // todo auto-generated method stub        try        {            linearlayout=new linearlayout(sactivecontext);            linearlayout.setlayoutparams(new layoutparams(layoutparams.fill_parent,layoutparams.fill_parent));             linearlayout.setorientation(linearlayout.vertical);            webview=new customwebview(sactivecontext);            framelayout layout=webview.createwebview();            onloadwebview();            linearlayout.addview(layout);            linearlayout.setid(sactionbar.getselectedtab().getposition());            return linearlayout;         }         catch(exception error)         {             system.out.println(error.getmessage());             return null;         }   } @override public void onactivitycreated() { super.onactivitycreated(); isinitialized=true; } @override public void onresume() { if(isinitialized)     onloadwebview(); } public void onloadwebview() { (int = 0; < arraylist.size(); i++) {                if(sactionbar.getselectedtab().getposition()==i)                {                    webview.initwebview(arraylist.get(i));                    mwebviewlist.add(i, webview);                    break;                }            } }    } 

Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -