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 3499716
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T12:38:44+00:00 2026-05-18T12:38:44+00:00

I have in my application 2 views: a. res/layout/main.xml – a standard view with

  • 0

I have in my application 2 views:

a. res/layout/main.xml – a standard view with 1 button

b. res/layout/web_view.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    >
         <WebView android:id="@+id/webview"
            android:layout_height="fill_parent"
            android:layout_width="fill_parent" />
</LinearLayout>

When I click the button on the first view(a), it loads the webview(b) and loads an url:

// click on the "Browser" button in view a
public void goToWebView(View view) {
        setContentView(R.layout.web_view);
        WebView mWebView = (WebView) findViewById(R.id.webview);
        mWebView.getSettings().setJavaScriptEnabled(true);
        mWebView.loadUrl("http://www.google.com");
    }

All that is working fine, the url load well but the browser is instantiated into its own view (a third one, not b itself) and my goal is to use the Webview to show some HTML code into my application, not outside of it, in a separate browser.

Anyboyd any idea?

This is done using API level8/Android 2.2.

Thanks for your help.
Paul

  • 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-05-18T12:38:44+00:00Added an answer on May 18, 2026 at 12:38 pm

    Actually I finally understood. Even if you programatically load the url with

    mWebView.loadUrl("http://www.google.com");
    

    you also have to mofify the default behaviour (which is opening an url in a new browser instance).
    The previous code needs 2 enhancements.

    // override default behaviour of the browser
    private class MyWebViewClient extends WebViewClient {
            @Override
            public boolean shouldOverrideUrlLoading(WebView view, String url) {
                view.loadUrl(url);
                return true;
            }
        }  
    

    Then, set for the view which uses Webclient the new behaviour:

    public void goToWebView(View view) {
            setContentView(R.layout.web_view);
            WebView mWebView = (WebView) findViewById(R.id.webview);
            // add the following line ----------
            mWebView.setWebViewClient(new MyWebViewClient());
            mWebView.getSettings().setJavaScriptEnabled(true);
            mWebView.loadUrl("http://www.google.com");
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Delphi 7 application that has two views of a document (e.g.
I am developing an application using MVC Preview 5. I have used typed views.
I have an application with a view containing several subviews. The subviews did not
I have a WinForms application with a view where the user selects a single
I have an application, built using MVC, that produces a view which delivers summary
I have a java application that is connected to a view on a remote
In my iPhone application I have a table view. When user taps any row,
I have created an iPhone application based on an OpenGL view. Now I would
I have a plug-in to an Eclipse RCP application that has a view. After
I have two threads in an Android application, one is the view thread, and

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.