1

I have a listview from which I pick the html file and I want the file to be displayed in webview which takes the 1/4 of a 10' tablet I try the following but nothing happens and I get a white webview

ListFiles.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id)
        {
            String filename = ListFiles.getItemAtPosition(position).toString();
            myweb.setInitialScale(1);
            myweb.getSettings().setJavaScriptEnabled(true);
            myweb.getSettings().setLoadWithOverviewMode(true);
            myweb.getSettings().setUseWideViewPort(true);
            myweb.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY);
            myweb.setScrollbarFadingEnabled(false);
            myweb.reload();
            myweb.loadUrl(dirFiles + "/" + filename);

        }
    });

2 Answers2

1

I converted to Uri with

String WebFile = dirFiles+"/"+filename;
Uri WebfileUri  = Uri.fromFile(new File(WebFile));
myweb.loadUrl(WebfileUri.toString());

and worked

0

try to below :-

File lFile = new File(Environment.getExternalStorageDirectory() + "<FOLDER_PATH_TO_FILE>/<FILE_NAME>");
WebView.loadUrl("file:///" + lFile.getAbsolutePath());
Patel Vicky
  • 766
  • 8
  • 17