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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T12:20:40+00:00 2026-05-29T12:20:40+00:00

What might be the reasons why the button is NULL? Button press; //… press

  • 0

What might be the reasons why the button is NULL?

Button press;
//...

press = (Button) findViewById (R.id.enter);

if (press != null)
press.setOnClickListener(this);

I checked the manifest, the xml file, the code… I don’t have any duplicate of R.id.enter, still the button is NULL… It all happened after I introduced a new Activity…

public void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    press = (Button) findViewById (R.id.enter);

    if (press != null)
    press.setOnClickListener(this);
}

the XML here (main.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"
android:background="@drawable/gift2"
>

<Button
android:id="@+id/enter"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="415dp"
android:background="@drawable/pattern"
android:layout_gravity="center_horizontal"
android:text="Open your box now!"
android:textSize="20sp"
/>

</LinearLayout>
  • 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-29T12:20:41+00:00Added an answer on May 29, 2026 at 12:20 pm

    One possibility is that the auto-generated R.java file has somehow got out of sync or has invalid values in it.

    In this case, R.id.enter may no longer be valid and as a result findViewById(R.id.enter) can no longer find a valid object to return.

    If using Eclipse, try using “Project -> Clean…” – this will delete all auto-generated files and re-create them.

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

Sidebar

Related Questions

I have the following code. When I press my save button, three requiredfieldvalidators run
I'm thinking that the reason I can't do this is because it might be
For some reason, nothing happens when I run this macro. What might I be
This might seem like a stupid question I admit. But I'm in a small
This might be on the discussy side, but I would really like to hear
This might be a bit on the silly side of things but I need
This might seem obvious but I've had this error when trying to use LINQ
This is for the usual PHP/SQL/html/CSS type of webdev. Site might be visited by
I don't undertand why I'm getting this error, code was working and running perfectly
For some unknown reasons this silly thing cant be implemented. I have an int

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.