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

  • SEARCH
  • Home
  • 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 the following application.xml <?xml version=1.0 encoding=utf-8?> <manifest xmlns:android=http://schemas.android.com/apk/res/android package=com.currency.mobile.android> <uses-permission android:name=android.permission.INTERNET/> <application
I have the following the layout file <?xml version=1.0 encoding=utf-8?> <RelativeLayout xmlns:android=http://schemas.android.com/apk/res/android xmlns:app=http://schemas.android.com/apk/res/com.company android:layout_width=fill_parent
In an MVC3 application I have a view rendering two Ajax partial views: a
I have an iOS application. Application has 2 different views: Main and Settings. In
I have an application and putting all of the layouts inside of the res/layout
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); Button OpenPDF = (Button) findViewById(R.id.button); OpenPDF.setOnClickListener(new View.OnClickListener()
I have an application with many views. I want only a couple of the
I have an application with several windows/views that show the same object. For example
I have a MVVM application that contains multiple views with some complex IsReadOnly rules
I have an iPad application and in one of my views i use UIScrollView

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.