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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T15:47:00+00:00 2026-05-19T15:47:00+00:00

xml and logcat now added, now custom view code, unfortunately i am away from

  • 0

xml and logcat now added,
now custom view code, unfortunately i am away from devel computer so i cant check your suggestions,
@jems, i may have the wrong constructor for my custom view?
@Falmarri, i think the build target is 2.2

Hopefully a simple thing I don’t know about:

I have a main game activity, and this calls a class which i have extended from the view class.
Here it is, in working form:

public class guappsXOMainGame extends Activity {

private static final int cellsX=10;
private static final int cellsY=10;

private guappsXOBoardView mBoardView;



@Override
public void onCreate(Bundle bund) {
    super.onCreate(bund);


    setContentView(R.layout.gamescreen);//loads xml layout called gamescreen
    mBoardView = (guappsXOBoardView) findViewById(R.id.boardview);

}

It all was going well, showing my game screen well, until I tried the following, which gives a force close:

public void onCreate(Bundle bund) {
    super.onCreate(bund);

    setContentView(R.layout.gamescreen);//loads xml layout called gamescreen
    mBoardView = (guappsXOBoardView) findViewById(R.id.boardview);
    mBoardView.hello();//problem line



}

What I want is to run a method that will get some info from the guappsxoboardview class, and this was the test case.
The method looks like this:

    public void hello(){

    int x = 1;

}

LogCat says:

01-29 20:50:46.415: INFO/ActivityManager(60): Starting activity: Intent { cmp=com.guapps/.guappsXOMainGame }
01-29 20:50:46.535: DEBUG/AndroidRuntime(564): Shutting down VM
01-29 20:50:46.535: WARN/dalvikvm(564): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
01-29 20:50:46.566: ERROR/AndroidRuntime(564): FATAL EXCEPTION: main
01-29 20:50:46.566: ERROR/AndroidRuntime(564): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.guapps/com.guapps.guappsXOMainGame}: java.lang.NullPointerException
01-29 20:50:46.566: ERROR/AndroidRuntime(564):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
01-29 20:50:46.566: ERROR/AndroidRuntime(564):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
01-29 20:50:46.566: ERROR/AndroidRuntime(564):     at android.app.ActivityThread.access$2300(ActivityThread.java:125)
01-29 20:50:46.566: ERROR/AndroidRuntime(564):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
01-29 20:50:46.566: ERROR/AndroidRuntime(564):     at android.os.Handler.dispatchMessage(Handler.java:99)
01-29 20:50:46.566: ERROR/AndroidRuntime(564):     at android.os.Looper.loop(Looper.java:123)
01-29 20:50:46.566: ERROR/AndroidRuntime(564):     at android.app.ActivityThread.main(ActivityThread.java:4627)
01-29 20:50:46.566: ERROR/AndroidRuntime(564):     at java.lang.reflect.Method.invokeNative(Native Method)
01-29 20:50:46.566: ERROR/AndroidRuntime(564):     at java.lang.reflect.Method.invoke(Method.java:521)
01-29 20:50:46.566: ERROR/AndroidRuntime(564):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
01-29 20:50:46.566: ERROR/AndroidRuntime(564):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
01-29 20:50:46.566: ERROR/AndroidRuntime(564):     at dalvik.system.NativeStart.main(Native Method)
01-29 20:50:46.566: ERROR/AndroidRuntime(564): Caused by: java.lang.NullPointerException
01-29 20:50:46.566: ERROR/AndroidRuntime(564):     at com.guapps.guappsXOMainGame.onCreate(guappsXOMainGame.java:38)
01-29 20:50:46.566: ERROR/AndroidRuntime(564):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
01-29 20:50:46.566: ERROR/AndroidRuntime(564):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
01-29 20:50:46.566: ERROR/AndroidRuntime(564):     ... 11 more
01-29 20:50:46.596: WARN/ActivityManager(60):   Force finishing activity com.guapps/.guappsXOMainGame
01-29 20:50:46.596: WARN/ActivityManager(60):   Force finishing activity com.guapps/.guappsXOStart
01-29 20:50:46.745: DEBUG/dalvikvm(60): GC_FOR_MALLOC freed 7966 objects / 468848 bytes in 99ms
01-29 20:50:47.108: WARN/ActivityManager(60): Activity pause timeout for HistoryRecord{44009a08 com.guapps/.guappsXOMainGame}
01-29 20:50:48.375: INFO/Process(564): Sending signal. PID: 564 SIG: 9
01-29 20:50:48.385: INFO/ActivityManager(60): Process com.guapps (pid 564) has died.
01-29 20:50:48.385: INFO/WindowManager(60): WIN DEATH: Window{440530d0 com.guapps/com.guapps.guappsXOStart paused=true}
01-29 20:50:48.445: WARN/InputManagerService(60): Got RemoteException sending setActive(false) notification to pid 564 uid 10032
01-29 20:50:57.482: WARN/ActivityManager(60): Activity destroy timeout for HistoryRecord{43fc4248 com.guapps/.guappsXOStart}
01-29 20:50:57.488: WARN/ActivityManager(60): Activity destroy timeout for HistoryRecord{44009a08 com.guapps/.guappsXOMainGame}

Here is the XML for this:

<?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:gravity="center_horizontal"
>

<com.guapps.guappsXOBoardView
    android:id="@+id/boardview"
    android:layout_width="match_parent"
    android:layout_height="match_parent"


    />

</LinearLayout>

Hopefully I have done something obvious wrong, thanks.

Now most of the custom view code also:

package com.guapps;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.RectF;
import android.util.AttributeSet;
import android.view.View;



public class guappsXOBoardView extends View {

    int screenHeight;
    int screenWidth;
    Context mContext;
    private float leftG;
    private float topG;
    private float rightG;
    private float botG;




    Bitmap boardGrid;




    public guappsXOBoardView(Context context, AttributeSet attrs) {
            super(context);
            requestFocus();


    }


    @Override
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec){

        screenWidth = View.MeasureSpec.getSize(widthMeasureSpec);
        screenHeight = View.MeasureSpec.getSize(heightMeasureSpec);

        setMeasuredDimension(screenWidth, screenHeight);


    }

    @Override
    protected void onDraw(Canvas canvas){



        canvas.drawColor(Color.WHITE);


         }
.....
  • 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-19T15:47:00+00:00Added an answer on May 19, 2026 at 3:47 pm

    thanks for you help, I found my bug.

    The constructor of my custom view had super(context); instead of super(context, attrs), which was causing findviewbyid to return null.

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

Sidebar

Related Questions

I am getting this error while trying to Parse the Xml response from the
I am trying to load an XML file from res/raw folder in my Android
The XML Schema Part 2 specifies that an instance of a datatype that is
This XML file contained archived news stories for all of last year. I was
The XML I'm trying to validate is as follows: <root> <element attribute=foo> <bar/> </element>
Which XML validation tools can you recommend for both performance and accuracy, each of
An XML attribute declared as xs:boolean can acceptable be true, false, 0 or 1.
I have a complete XML document in a string and would like a Document
I have an XML object (loaded using XMLHTTPRequest 's responseXML ). I have modified
I'm generating some XML documents and when it comes to the address part I

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.