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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T20:55:14+00:00 2026-06-17T20:55:14+00:00

Here is an app that I am making to keep score for spades and

  • 0

Here is an app that I am making to keep score for spades and eventually other card games. I am getting a null pointer exception error and am not sure where it is or what is wrong. Thanks for any help anyone can give.

here is my java file

package com.innovativesolutions.cardscorekeeper;


import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.EditText;

public class MainActivity extends Activity {

    int scorea, scoreb, takea[], takeb[], bida[], bidb[], baga, bagb, iii;
    EditText bidaa, bidbb, actuala, actualb, totala, totalb;
    Button total;
    CheckBox nila, nilb, gnila, gnilb;

    @Override
        public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        iii = 0;
        baga = 0;
        bagb = 0;
        scorea = 0;
        scoreb = 0;
        total = (Button) findViewById(R.id.button1);
        bidaa = (EditText) findViewById(R.id.abid);
        bidbb = (EditText) findViewById(R.id.bbid);
        actuala = (EditText) findViewById(R.id.atake);
        actualb = (EditText) findViewById(R.id.btake);
        totala = (EditText) findViewById(R.id.atotal);
        totalb = (EditText) findViewById(R.id.btotal);
        nila = (CheckBox) findViewById(R.id.anil);
        nilb = (CheckBox) findViewById(R.id.bnil);
        gnila = (CheckBox) findViewById(R.id.agnil);
        gnilb = (CheckBox) findViewById(R.id.bgnil);
        total.setOnClickListener(new View.OnClickListener() {

            public void onClick(View v) {
                // TODO Auto-generated method stub
                bida[iii]=Integer.parseInt(bidaa.getText().toString());
                bidb[iii]=Integer.parseInt(bidbb.getText().toString());
                takea[iii]=Integer.parseInt(actuala.getText().toString());
                takeb[iii]=Integer.parseInt(actualb.getText().toString());


                if (nila.isChecked()){
                    if (gnila.isChecked() && takea[iii]>=bida[iii]){
                    baga = takea[iii]-bida[iii]+baga;
                    scorea = scorea + 100 + (bida[iii]*10);
                    } 
                    else {scorea = scorea - 100 - (bida[iii]*10);}
                } else {
                    if (takea[iii]>=bida[iii]){
                        baga = takea[iii]-bida[iii]+baga;
                        scorea = scorea + (bida[iii]*10);
                    } else {scorea = scorea - (bida[iii]*10);}

                }

                if (nilb.isChecked()){
                    if (gnilb.isChecked() && takeb[iii]>=bidb[iii]){
                    bagb = takeb[iii]-bidb[iii]+bagb;
                    scoreb = scoreb + 100 + (bidb[iii]*10);
                    } else {scoreb = scoreb - 100 - (bidb[iii]*10);}
                } else {
                    if (takeb[iii]>=bidb[iii]){
                        bagb = takeb[iii]-bidb[iii]+bagb;
                        scoreb = scoreb + (bidb[iii]*10);
                    } else {scoreb = scoreb - (bidb[iii]*10);}

                }               


                if (baga>=10){
                    scorea = scorea - 100;
                    baga = 0;
                }
                if (bagb>=10){
                    scoreb = scoreb - 100;
                    bagb = 0;
                }

                iii++;
                totala.setText(scorea);
                totalb.setText(scoreb);

        }
        });


            }}

and here is my xml file

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

    <RadioGroup
        android:id="@+id/radioGroup1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true" >

        <RadioButton
            android:id="@+id/radio0"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:checked="true"
            android:text="Spades" />

        <RadioButton
            android:id="@+id/radio1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Rook" />
    </RadioGroup>

    <EditText
        android:id="@+id/editText3"
        android:layout_width="100dp"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_below="@+id/radioGroup1"
        android:layout_marginLeft="70dp"
        android:ems="10"
        android:text="Team A"
        android:textSize="20dp" />

    <EditText
        android:id="@+id/editText4"
        android:layout_width="100dp"
        android:layout_height="wrap_content"
        android:layout_below="@+id/radioGroup1"
        android:layout_marginLeft="50dp"
        android:layout_toRightOf="@+id/editText3"
        android:ems="10"
        android:text="Team B"
        android:textSize="20dp" />

    <Button
        android:id="@+id/button1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_marginLeft="75dp"
        android:layout_marginTop="20dp"
        android:layout_toRightOf="@+id/radioGroup1"
        android:text="Add Round" />

    <TextView
        android:id="@+id/textView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_below="@+id/editText3"
        android:text="Bid"
        android:textSize="20dp" />

    <TextView
        android:id="@+id/textView2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_below="@+id/textView1"
        android:text="Taken"
        android:textSize="20dp" />

    <EditText
        android:id="@+id/abid"
        android:layout_width="50dp"
        android:layout_height="wrap_content"
        android:layout_alignBottom="@+id/textView1"
        android:layout_toRightOf="@+id/textView2"
        android:ems="10"
        android:inputType="number"
        android:text="1"
        android:textSize="20dp" />

    <EditText
        android:id="@+id/bbid"
        android:layout_width="50dp"
        android:layout_height="wrap_content"
        android:layout_above="@+id/textView2"
        android:layout_marginLeft="50dp"
        android:layout_toRightOf="@+id/editText3"
        android:ems="10"
        android:inputType="number"
        android:text="2"
        android:textSize="20dp" />

    <EditText
        android:id="@+id/btake"
        android:layout_width="100dp"
        android:layout_height="wrap_content"
        android:layout_alignLeft="@+id/editText4"
        android:layout_alignRight="@+id/bbid"
        android:layout_alignTop="@+id/textView2"
        android:ems="10"
        android:inputType="number"
        android:text="1"
        android:textSize="20dp" />

    <CheckBox
        android:id="@+id/anil"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignBaseline="@+id/abid"
        android:layout_alignBottom="@+id/abid"
        android:layout_toRightOf="@+id/abid"
        android:checked="false"
        android:text="Nil?" />

    <CheckBox
        android:id="@+id/bnil"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignBaseline="@+id/bbid"
        android:layout_alignBottom="@+id/bbid"
        android:layout_alignParentRight="true"
        android:text="Nil?" />

    <CheckBox
        android:id="@+id/bgnil"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignBaseline="@+id/btake"
        android:layout_alignBottom="@+id/btake"
        android:layout_alignParentRight="true"
        android:text="Nil?" />

    <EditText
        android:id="@+id/atake"
        android:layout_width="50dp"
        android:layout_height="wrap_content"
        android:layout_alignLeft="@+id/editText3"
        android:layout_below="@+id/abid"
        android:ems="10"
        android:inputType="number"
        android:text="2"
        android:textSize="20dp" />

    <CheckBox
        android:id="@+id/agnil"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignBaseline="@+id/atake"
        android:layout_alignBottom="@+id/atake"
        android:layout_centerHorizontal="true"
        android:checked="false"
        android:text="Nil?" />

    <EditText
        android:id="@+id/btotal"
        android:layout_width="100dp"
        android:layout_height="wrap_content"
        android:layout_alignBaseline="@+id/atotal"
        android:layout_alignBottom="@+id/atotal"
        android:layout_alignParentRight="true"
        android:ems="10"
        android:inputType="number"
        android:text="0" >

        <requestFocus />
    </EditText>

    <EditText
        android:id="@+id/atotal"
        android:layout_width="100dp"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_below="@+id/atake"
        android:layout_marginTop="30dp"
        android:ems="10"
        android:text="0" />

</RelativeLayout>
  • 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-17T20:55:15+00:00Added an answer on June 17, 2026 at 8:55 pm

    Just you need to initalize all the arrays on integer which you have declared.
    Initialize all this in your onCreate() as below:

       @Override
        public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        iii = 0;
        baga = 0;
        bagb = 0;
        scorea = 0;
        scoreb = 0;
        bida=new int[10];
        bidb=new int[10];
        takea=new int[10];
        takeb=new int[10];
        ........................
     }
    

    Also parse the value of integer to set in the TextView as below:

              totala.setText(String.valueOf(scorea));
                totalb.setText(String.valueOf(scoreb));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm making an app that will ask for an existing contact, then keep some
making a coin flip option within an app. Here's the part that's killing me:
So here is the thing. I'm making an app that uses backboneJS. I currently
I am writing an app that interfaces with the iPhone address book. Here is
I have a main app that will have many plugins. Here is the PluginReader
I have a MySQL/Rails app that needs search. Here's some info about the data:
Here is my situation. I have an app that is composed almost entirely using
so here is the problem. I am currently creating an Android app that is
Here's the issue: I have a list of App names that I want to
I found here that to restore brightness on app exit you have to use

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.