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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T07:20:53+00:00 2026-06-09T07:20:53+00:00

Having a really odd problem when trying to create a web view in an

  • 0

Having a really odd problem when trying to create a web view in an activity.

I was following the Android WebView guide to do this (http://developer.android.com/guide/webapps/webview.html)

My app has a main menu with a button on it that leads to an activity that is supposed to open a web view. It works just fine when I use an Intent, but I need more flexibility so that isn’t really an option.

Here is my webview.xml file:

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

This is what is in my WebView Activity file:

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    WebView webview = (WebView) findViewById(R.id.webview);
    diningWebView.loadUrl(http://www.google.com);
}

The problem is that my findViewById() is returning null, but I don’t know why.

Any ideas?

  • 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-09T07:21:02+00:00Added an answer on June 9, 2026 at 7:21 am

    You forgot your setContentView()

    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView( R.layout.webview );   
    
        WebView webview = (WebView) findViewById(R.id.webview);
        diningWebView.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

Currently having this really odd problem with my layout IE7. I'm not very experienced
I am having a really odd problem trying to set a simple float value
I have been having these really odd problems with Visual Studio 2010. At this
I'm really having a problem finding out how to fix this. I cannot seem
hey guys having this really simple problem but cant seem to figure out have
I'm having this really mind breaking problem. I created a Localizable.strings file in XCode
Having a really small problem. This is a pointer program I tried to make
I'm having a really odd problem (which usually means I'm doing something wrong) with
I am having a really odd problem with Flash CS4. I have a MovieClip
I've got a really odd problem when building a project in VS2008. Having made

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.