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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T05:12:50+00:00 2026-05-24T05:12:50+00:00

Here is my main class: import android.graphics.Rect; import android.util.Log; import android.view.MotionEvent; import android.view.View; import

  • 0

Here is my main class:

import android.graphics.Rect;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
import android.widget.RelativeLayout;

public final class HomeScreen implements OnTouchListener
{
    public HomeScreen(Viewer view) 
    {
        this.view = view;
        RelativeLayout layout = (RelativeLayout)view.findViewById(R.id.home_screen_lay);
        layout.setOnTouchListener(this); // this is where the error points to
        network.setFocus(this);
        view.setContentView(R.layout.home);
    }

    public boolean onTouch(View v, MotionEvent e) 
    {
        switch(e.getAction())
        {
            case MotionEvent.ACTION_DOWN:
                onPress(v,e);
                break;
            case MotionEvent.ACTION_MOVE:
                onMove(v,e);
                break;
            case MotionEvent.ACTION_UP:
                onRelease(v,e);
                break;
        }
        return true;
    }

    public void onPress(View v, MotionEvent e)
    {
        for(int x=0;x<buttons.length;x++)
        {
            if(buttons[x].contains((int)e.getX(),(int)e.getY()))
            {
                if(buttons[x]==exitRect)
                    view.finish();
                if(buttons[x]==newUserRect)
                    new NewUser(view,network);
                if(buttons[x]==loginRect)
                    new Login(view,network);
            }
        }
    }
    public void onMove(View v, MotionEvent e){}
    public void onRelease(View v, MotionEvent e){}

    public void handleMessage(String message){}
    private NetworkManager network;
    private Viewer view;
    private Rect loginRect;
    private Rect newUserRect;
    private Rect exitRect;
    private Rect[] buttons;
}

and heres home.xml:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/home_screen_lay"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/home_screen">
</RelativeLayout>

The NullPointerExeption points to that line in my HomeScreen class, it says that layout is null. I have been looking at this for hours and i cant see whats wrong. Can someone else see what I’m missing? All relevant answers are welcome!

  • 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-24T05:12:51+00:00Added an answer on May 24, 2026 at 5:12 am

    What if you move:

    view.setContentView(R.layout.home);
    

    to the top of the method before you try to get the layout object?

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

Sidebar

Related Questions

Here is a sample code: public class TestIO{ public static void main(String[] str){ TestIO
What am I doing wrong here: class Helo { // main: generate some simple
Here is my code : public static void main(String[] args) { // System.setProperty( //
Here's the code snippet: public static void main (String[]arg) { char ca = 'a'
Here is a quick test program: public static void main( String[] args ) {
i try to create small example to test GPS here package org.example.location; import com.google.android.maps.MapActivity;
I am trying to implement a custom titlebar: Here is my Helper class: import
Here is my main page code: <form><iframe name=iframe_pic src=iframe.html></iframe></form> Here is my iframe.html: <script
here's the main code at first I thought is was the message box but
I'm looking for a way to monitor system statistics. Here are my main points

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.