Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9314327
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 19, 20262026-06-19T02:06:25+00:00 2026-06-19T02:06:25+00:00

I use webView1 + local html file like a custom navigation bar with some

  • 0

I use webView1 + local html file like a custom navigation bar with some links.

When the link is clicked, the asked html file must load in webView2.

Is this possible?

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setRequestedOrientation (ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); // Fixed Portrait orientation
    requestWindowFeature(Window.FEATURE_NO_TITLE); // No app title bar
    setContentView(R.layout.activity_main);

    myNavbarView = (WebView)findViewById(R.id.navbarView);
    myNavbarView.getSettings().setJavaScriptEnabled(true);
    myNavbarView.setVerticalScrollBarEnabled(false);
    myNavbarView.setHorizontalScrollBarEnabled(false);
    myNavbarView.setWebViewClient(new WebViewClient());
    myNavbarView.loadUrl("file:///android_asset/HTML/navbar.html");

    myWebView = (WebView)findViewById(R.id.webView);
    myWebView.getSettings().setJavaScriptEnabled(true);
    //hack to load twitter
    myWebView.getSettings().setUserAgentString("Mozilla/5.0 (Linux; U; Android 2.0; en-us; Droid Build/ESD20) AppleWebKit/530.17 (KHTML, like Gecko) Version/4.0 Mobile Safari/530.17");
    myWebView.setVerticalScrollBarEnabled(false);
    myWebView.loadUrl("file:///android_asset/HTML/index.html");
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-19T02:06:26+00:00Added an answer on June 19, 2026 at 2:06 am

    Simplefied work out from this example:
    http://blog.objectgraph.com/index.php/2012/03/16/android-development-javascript-bridge-example-fully-explained/

    JavaScriptHandler.java

    public class JavaScriptHandler {
        MainActivity parentActivity;
        public JavaScriptHandler(MainActivity activity)  {
            parentActivity = activity;
        }
        public void setResultUrl(String url){
            this.parentActivity.javascriptCallUrl(url);
        }
    }
    

    MainActivity.java

    // add line:
    myNavbarView.addJavascriptInterface(new JavaScriptHandler(this), "MyHandler");
    
    // Verwerk calls van navbar.html via JavaScriptHandler.java
    public void javascriptCallUrl(final String url){
        Log.v(TAG, "MainActivity JSHandler used: " + url);
        // I need to run set operation of UI on the main thread.
        // therefore, the above parameter "url" must be final
        runOnUiThread(new Runnable() {
            public void run() {
               myWebView.loadUrl(url);
            }
        });
    }
    

    navbar.html

    <a href="#" onclick="window.MyHandler.setResultUrl('file:///android_asset/HTML/index.html')">...</a>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I use this line of code to load a local html file into a
I've putted a webview and with this code I use it with local html.
I'm trying to use jFontSize in a local html page to be displayed in
No, like others, I don't want to use custom fonts. I am looking for
My app is using webview and loads a local html file in the assets/
I use a UIWebView to load a local html, and there is a PNG
I have a local HTML page which doesn't has any external link(css or images..)
I use WebView + addJavascriptInterface to control my app from html page shown in
In my application I use only WebView for loading index.html where running all app
use C#,want to upload excel file on google doc. bellow syntax use to upload

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.