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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T14:19:11+00:00 2026-05-19T14:19:11+00:00

I am trying to create a simple webview and I am getting FC on

  • 0

I am trying to create a simple webview and I am getting FC on each start.

Here is my MainActivity.java file:

package com.jerdog.apps;

import android.app.Activity;
import android.os.Bundle;
import android.webkit.WebView;

public class MainActivity extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        WebView myWebView = (WebView) findViewById(R.layout.main);
        myWebView.loadUrl("http://www.google.com");
    }
}

and here is my res/layout/main.xml file

<?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"
    >
<TextView  
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:text="@string/hello"
    />
<WebView  xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/webview"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
/>
</LinearLayout>

I am including my logcat from the moment I press Run in Eclipse at pastebin

http://pastebin.com/5trRw9Bd

  • 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-19T14:19:11+00:00Added an answer on May 19, 2026 at 2:19 pm

    This line:

    WebView myWebView = (WebView) findViewById(R.layout.main);
    

    is incorrect, and myWebView is null. Thus the following line throws the NullPointerException

    Change the line to:

    WebView myWebView = (WebView) findViewById(R.id.webview);
    

    findViewById takes the id of the View you wish to find as an input, however you were passing in your layout. Changing this to the id of the WebView element from your main.xml file should fix the issue. There is a tutorial if you need a reference implementation.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Im trying to create a simple dll file.Im following the tutorial http://java.sun.com/docs/books/jni/html/start.html when i
I'm studying webrat and cucumber and trying to create simple example. Here is my
Iam trying to create simple menu according to the book CCMenuItem . here is
I'm trying to create simple slot machine with three slots. Each slot will generate
I'm trying to create a simple dynamic gallery with a radio button under each
I'm trying create simple application in C++. This application has to read from file
I am trying to create simple user registration form. I have an index.html file
Im trying to create a simple pan and zoom app using silverlight 4, but
Im trying to create a simple input box with form validation, but im not
I'm trying to create a simple Add-On for SQL Server 2008; it is simply

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.