Go Back   Android Forums > Android Development > Application Development
Application Development Dev lounge for our application developers.

Get excited for the Samsung Galaxy S5! Find everything you need and discuss it in our Galaxy S5 Forum!

test: Reply
 
LinkBack Thread Tools
Old January 6th, 2013, 09:56 AM   #1 (permalink)
New Member
Thread Author (OP)
 
Join Date: Apr 2011
Posts: 4
 
Device(s):
Carrier: Not Provided

Thanks: 1
Thanked 0 Times in 0 Posts
Default need help with error in app

[HIGH]
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 bid1aa, bid1bb, 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);
bid1aa = (EditText) findViewById(R.id.a1bid);
bid1bb = (EditText) findViewById(R.id.b1bid);
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(bid1aa.getText().toString());
bidb[iii]=Integer.parseInt(bid1bb.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);

}
});


}}




[/HIGH]

*******************and here is my xml file

[HIGH]
<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/atotal"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_marginLeft="50dp"
android:ems="10"
android:text="13" >

<requestFocus />
</EditText>

<EditText
android:id="@+id/btotal"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_marginLeft="50dp"
android:ems="10"
android:inputType="number"
android:text="13" />

<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/a1bid"
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="0"
android:textSize="20dp" />

<EditText
android:id="@+id/b1bid"
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="0"
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/b1bid"
android:layout_alignTop="@+id/textView2"
android:ems="10"
android:inputType="number"
android:text="0"
android:textSize="20dp" />

<CheckBox
android:id="@+id/anil"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/a1bid"
android:layout_alignBottom="@+id/a1bid"
android:layout_toRightOf="@+id/a1bid"
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/b1bid"
android:layout_alignBottom="@+id/b1bid"
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/a1bid"
android:ems="10"
android:inputType="number"
android:text="0"
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?" />

</RelativeLayout>

[/HIGH]


For some reason I keep getting a force close error and I am not really good at using logcat yet so any help would be appreciated. This is the start a app i am making to keep score for spades.

willocks1718 is offline  
Reply With Quote
sponsored links
Old January 6th, 2013, 05:02 PM   #2 (permalink)
Junior Member
 
Join Date: Aug 2012
Posts: 29
 
Device(s): Virgin Mobile HTC Evo V
Carrier: Not Provided

Thanks: 17
Thanked 7 Times in 7 Posts
Default

Zip and send me your app and I will find out what's making it crash
redpipe is offline  
Reply With Quote
Old January 6th, 2013, 10:06 PM   #3 (permalink)
Senior Member
 
jonbonazza's Avatar
 
Join Date: Jul 2010
Gender: Male
Posts: 1,936
 
Device(s): Nexus 4, Samsung Galaxy S II, HTC Evo 4G, Amazon Kindle Fire
Carrier: ATT

Thanks: 235
Thanked 478 Times in 292 Posts
Default

Can you post the log cat output?
__________________
My blog, Inverted Keystrokes, is looking for aspiring developers (not necessarily with Android) to post articles. If you have any development experience and are interested in participating, please PM me. =)
jonbonazza is offline  
Reply With Quote
Old January 7th, 2013, 10:55 AM   #4 (permalink)
Junior Member
 
Join Date: Apr 2012
Location: London
Posts: 98
 
Device(s): ZTE Skate, Ainol Novo7 Aurora
Carrier: Not Provided

Thanks: 2
Thanked 24 Times in 23 Posts
Default

It looks like you have defined a load of arrays but not actually constructed them. I guess it crashes with a null pointer exception when you call:

[HIGH]bida[iii]=Integer.parseInt(bid1aa.getText().toString())[/HIGH]Call bida = new int[10]; to construct an array big enough to hold 10 integers (do all the rest too). You will need to make sure iii doesn't get bigger than the size of the array.
GeorgeN is offline  
Reply With Quote
Reply
Tags
app, beginner, help a noob, programming


Go Back   Android Forums > Android Development > Application Development
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -5. The time now is 09:57 AM.
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.