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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T02:00:36+00:00 2026-06-13T02:00:36+00:00

This is a topic that seems to have been broadly covered, yet I cannot

  • 0

This is a topic that seems to have been broadly covered, yet I cannot figure out what is causing my problem. I am using a tab layout on my application, and they all work fine with the exception of one that throws this:

E/AndroidRuntime(1190): Caused by: java.lang.NullPointerException
E/AndroidRuntime(1190): at com.package.Example.onCreate(clas.java:62)
 E/AndroidRuntime(1190): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)

I have found the line that is causing the problem (62), but I am baffled because I have this coded the same way in 5 other instances. What I have found for a java.lang.NullPointerException is that this is called when something is not referenced, but this is not the case, as I have it referenced in my onCreate. Here is my class with the bolded line the one causing my issues. Thank you for your help!

public class Example extends Activity implements OnClickListener{

    ImageButton image1;
    ImageButton glow1;
    WebView webview1;



    @Override
    protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);
        setContentView(R.layout.examplelayout);

        final ImageButton image1 = (ImageButton)findViewById(R.id.webgoogle);
        final ImageButton glow1 = (ImageButton)findViewById(R.drawable.googleglow);
        final WebView webview1 = (WebView)this.findViewById(R.id.webView6);
        final MediaPlayer sound = MediaPlayer.create(Youtube.this, R.raw.appsound);

        image1.setOnClickListener(new View.OnClickListener() {

            public void onClick(View v) {
                // TODO Auto-generated method stub
                webview1.loadUrl("http://www.google.com");
                if(sound.isPlaying()){
                image1.setVisibility(ImageButton.VISIBLE);
                glow1.setVisibility(ImageButton.GONE);




            }else {
                sound.start();
                image1.setVisibility(ImageButton.GONE);
                glow1.setVisibility(ImageButton.VISIBLE);

            }
            }
        });

        **glow1.setOnClickListener(new View.OnClickListener() {**

            public void onClick(View v) {
                // TODO Auto-generated method stub
            webview1.loadUrl("http://www.google.com");
            if(sound.isPlaying()){
            glow1.setVisibility(ImageButton.GONE);
            image1.setVisibility(ImageButton.VISIBLE);

        }else {
            sound.start();
            glow1.setVisibility(ImageButton.VISIBLE);
            image1.setVisibility(ImageButton.GONE);
        }
        }
        });
  • 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-13T02:00:37+00:00Added an answer on June 13, 2026 at 2:00 am

    Found your problem,

     final ImageButton glow1 = (ImageButton)findViewById(R.drawable.googleglow);
    

    This should be,

     final ImageButton glow1 = (ImageButton)findViewById(R.id.googleglow);
    

    You are casting the res wrongly with Drawable and id.

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

Sidebar

Related Questions

There have been a couple of threads on this topic in the past that
I have been trying to find this issue here, but no topic seems to
There have been many threads that correspond to this topic. What’s the current state
I know that this topic has been beaten to death, but it seems that
I only read a little bit about this topic, but it seems that the
I've looked in various resources regarding this topic, and it seems to me that
There are several other questions about this topic that I have gone through, but
At first, i have to say that this topic is very common topic. I
First, let me just say that I have searched for information on this topic;
So I know there have been a couple of posts around about this topic,

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.