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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T05:18:00+00:00 2026-05-23T05:18:00+00:00

I have an activity that shows a game screen. One of the UI elements

  • 0

I have an activity that shows a game screen. One of the UI elements is a score box. The score box is basically a Table Layout with four rows. All the rows are the same here is the xml representing one row.

<TableRow
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <ImageView
        android:id="@+id/farkle_image"
        android:src="@drawable/icon"
        android:layout_height="wrap_content"
        android:layout_width="wrap_content"
        android:layout_weight="1" />
    <TextView
        android:id="@+id/name_text"
        android:layout_weight="1"
        android:layout_height="wrap_content"
        android:layout_width="wrap_content"
        android:text="Name" />
    <TextView
        android:id="@+id/temp_score_text"
        android:layout_weight="1"
        android:layout_height="wrap_content"
        android:layout_width="wrap_content"
        android:text="Temp Score" />
    <TextView
        android:id="@+id/score_text"
        android:layout_weight="1"
        android:layout_height="wrap_content"
        android:layout_width="wrap_content"
        android:text="Score" />
</TableRow>

Each row then has imageview , a textview representing the player name, and two other textviews representing various scores.

Here is what I do in the layout used by the activity:

<TableLayout
        android:id="@+id/score_box"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_below="@+id/score_button">

        <include
            layout="@layout/score_box_row"
            android:id="@+id/row_1" />

        <include
            layout="@layout/score_box_row"
            android:id="@+id/row_2"
            android:layout_below="@+id/row_1" />

        <include
            layout="@layout/score_box_row"
            android:id="@+id/row_3"
            android:layout_below="@+id/row_2" />

        <include
            android:id="@+id/row_4"
            layout="@layout/score_box_row"
            android:layout_below="@+id/row_3" />

    </TableLayout>

The game can be played with 2 to 4 players so what I had in mind was to set the Visibility of the Rows without respective player to View.GONE .

The only problem is that I cannot “find” the rows. findViewById() returns null. This method is called from onCreate() right after setContentView()

private void initializeArrays() {

        TableLayout table = (TableLayout) findViewById(R.id.score_box);
        Log.w(getClass().getName(), "Child Count: " + table.getChildCount());

        rows = ArrayList<TableRow>();    
        rows.add((TableRow) findViewById(R.id.row_1)); //Line 95
        rows.add((TableRow) findViewById(R.id.row_2));
        rows.add((TableRow) findViewById(R.id.row_3));
        rows.add((TableRow) findViewById(R.id.row_4));

        letters[0] = R.drawable.f;
        letters[1] = R.drawable.a;
        letters[2] = R.drawable.r;
        letters[3] = R.drawable.k;
        letters[4] = R.drawable.l;
        letters[5] = R.drawable.e;

    }

I always get a NullPointerException at runtime. The TableRows are there because table.getChildCount() returns 4. I’m not sure what is wrong.

Is this a bug with android or a bug with eclipse?

EDIT: As requested here is the stack:

06-14 15:59:40.437: WARN/dalvikvm(1587): threadid=1: thread exiting with uncaught exception (group=0x40015560)
06-14 15:59:40.441: ERROR/AndroidRuntime(1587): FATAL EXCEPTION: main
06-14 15:59:40.441: ERROR/AndroidRuntime(1587): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.mikgonz.farkle/com.mikgonz.farkle.ui.GameScreen}: java.lang.NullPointerException
06-14 15:59:40.441: ERROR/AndroidRuntime(1587):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1768)
06-14 15:59:40.441: ERROR/AndroidRuntime(1587):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1784)
06-14 15:59:40.441: ERROR/AndroidRuntime(1587):     at android.app.ActivityThread.access$1500(ActivityThread.java:123)
06-14 15:59:40.441: ERROR/AndroidRuntime(1587):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:939)
06-14 15:59:40.441: ERROR/AndroidRuntime(1587):     at android.os.Handler.dispatchMessage(Handler.java:99)
06-14 15:59:40.441: ERROR/AndroidRuntime(1587):     at android.os.Looper.loop(Looper.java:130)
06-14 15:59:40.441: ERROR/AndroidRuntime(1587):     at android.app.ActivityThread.main(ActivityThread.java:3835)
06-14 15:59:40.441: ERROR/AndroidRuntime(1587):     at java.lang.reflect.Method.invokeNative(Native Method)
06-14 15:59:40.441: ERROR/AndroidRuntime(1587):     at java.lang.reflect.Method.invoke(Method.java:507)
06-14 15:59:40.441: ERROR/AndroidRuntime(1587):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:847)
06-14 15:59:40.441: ERROR/AndroidRuntime(1587):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:605)
06-14 15:59:40.441: ERROR/AndroidRuntime(1587):     at dalvik.system.NativeStart.main(Native Method)
06-14 15:59:40.441: ERROR/AndroidRuntime(1587): Caused by: java.lang.NullPointerException
06-14 15:59:40.441: ERROR/AndroidRuntime(1587):     at com.mikgonz.farkle.ui.GameScreen.initializeArrays(GameScreen.java:95)
06-14 15:59:40.441: ERROR/AndroidRuntime(1587):     at com.mikgonz.farkle.ui.GameScreen.onCreate(GameScreen.java:48)
06-14 15:59:40.441: ERROR/AndroidRuntime(1587):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
06-14 15:59:40.441: ERROR/AndroidRuntime(1587):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1722)
06-14 15:59:40.441: ERROR/AndroidRuntime(1587):     ... 11 more
  • 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-23T05:18:01+00:00Added an answer on May 23, 2026 at 5:18 am

    First, it looks like that should be

    rows = new ArrayList<TableRow>();
    

    I’m surprised that that line compiled at all, if it did.

    Also, and this would be a silly error, make sure that the score_box_row layout file actually exists and defines a layout properly.

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

Sidebar

Related Questions

Basically, I have a field in my table that shows when the latest activity
I have an activity that shows up when the phone screen goes to sleep/turns
i have problems with my game. I have an Main Activity that's shows a
I have an app that, after some clicking, shows activity with news contents. I
I Have activity that get some data from the internet, and shows it to
I have a little function that shows latest activity, it grab timestamp in unix
I have an activity that shows customer information. All the controls are drawn dynamically
I'm writing my first Android application and I have one activity that I'd like
I have implemented a UIActivityIndicator that shows up in one part of my program
I want my app to have an activity that shows instruction on how to

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.