Having a string of numbers display on click.

  • (2 Pages)
  • +
  • 1
  • 2

29 Replies - 5282 Views - Last Post: 25 September 2012 - 02:06 PM

#1 izic  Icon User is offline

  • D.I.C Head

Reputation: -2
  • View blog
  • Posts: 197
  • Joined: 15-January 09

Having a string of numbers display on click.

Posted 22 September 2012 - 08:02 PM

Hi, I'm working on a simple calculator similar to the calculator you can use by going to All Programs > Accessories on your computer. I'm trying to have the user enter the numbers to be calculated by pressing buttons and this works if I enter "1" but if I try to enter "100" the "1" disappears and there's only a "0". What can I so my EditText box shows "100" when the user presses 100 instead of showing 0?


package app.droidcalc; 

import app.droidcalc.R;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

public class DroidCalcActivity extends Activity 
{
    Button one, two, three, four, five, six, seven, 
    eight, nine, zero, clr, bksp, add, sub, mult, eql, deci, div;
    EditText calculations;
    
    
	@Override 
	public void onCreate(Bundle savedInstanceState) 
	{ 
		super.onCreate(savedInstanceState); 
		setContentView(R.layout.main); 
		/*val1=(EditText) findViewById(R.id.edVal1); 
		val2=(EditText) findViewById(R.id.edVal2); 
		ans=(TextView) findViewById(R.id.tvAns );*/ 
		calculations=(EditText)findViewById(R.id.calc);
		one=(Button) findViewById(R.id.num1); 
		two=(Button)findViewById(R.id.num2); 
		three=(Button) findViewById(R.id.num3); 
		four=(Button) findViewById(R.id.num4); 
		five=(Button)findViewById(R.id.num5); 
		six=(Button) findViewById(R.id.num6); 
		seven=(Button) findViewById(R.id.num7); 
		eight=(Button)findViewById(R.id.num8); 
		nine=(Button) findViewById(R.id.num9); 
		zero=(Button) findViewById(R.id.button0);
		bksp=(Button) findViewById(R.id.backspace);
		clr=(Button) findViewById(R.id.clear);
		add=(Button) findViewById(R.id.addition);
		sub=(Button) findViewById(R.id.subtraction);
		mult=(Button) findViewById(R.id.multiplication);
		eql=(Button) findViewById(R.id.equalsign);
		deci=(Button) findViewById(R.id.buttonDecimal);
		div=(Button) findViewById(R.id.division);
		
		one.setonclickListener(new Button.onclickListener() {
	    @Override
		public void onclick(View v) 
	    {
	        CharSequence text= one.getText();
	    	calculations.setText(text); 
		}
		});
		
		two.setonclickListener(new Button.onclickListener() {
		@Override
		public void onclick(View v) 
		{
			CharSequence text= two.getText();
	    	calculations.setText(text); 	 
		}
		});
		
		three.setonclickListener(new Button.onclickListener() {
		public void onclick(View v) 
		{
			CharSequence text= three.getText();
	    	calculations.setText(text); 	 
		}
		});

		four.setonclickListener(new Button.onclickListener() {
		public void onclick(View v) 
		{
			CharSequence text= four.getText();
	    	calculations.setText(text); 
		}
		});
		
		five.setonclickListener(new Button.onclickListener() {
		public void onclick(View v) 
		{
			CharSequence text= five.getText();
	    	calculations.setText(text); 
		}
		});
		
		six.setonclickListener(new Button.onclickListener() {
		public void onclick(View v) 
		{
			CharSequence text= six.getText();
	    	calculations.setText(text); 
		}
		});
		
		seven.setonclickListener(new Button.onclickListener() {
		public void onclick(View v) 
		{
			CharSequence text= seven.getText();
	    	calculations.setText(text);     	 
		}
		});
		
		eight.setonclickListener(new Button.onclickListener() {
		public void onclick(View v) 
		{
			CharSequence text= eight.getText();
	    	calculations.setText(text);     	 
		}
		});
		
		nine.setonclickListener(new Button.onclickListener() {
		public void onclick(View v) 
		{
			CharSequence text= nine.getText();
	    	calculations.setText(text);     	 
		}
		});
		
		zero.setonclickListener(new Button.onclickListener() {
		public void onclick(View v) 
		{
			CharSequence text= zero.getText();
	    	calculations.setText(text);     	 
		}
		});
		
			  
		 
		
	} 
	 
}


Is This A Good Question/Topic? 0
  • +

Replies To: Having a string of numbers display on click.

#2 EndLessMind  Icon User is offline

  • These are the droids you're looking for
  • member icon

Reputation: 194
  • View blog
  • Posts: 1,099
  • Joined: 13-March 09

Re: Having a string of numbers display on click.

Posted 23 September 2012 - 02:12 AM

Every time you call setText(); the old value is overwritten.
Try using calculations.setText(calculations.getText() + text);

This post has been edited by EndLessMind: 23 September 2012 - 08:26 AM

Was This Post Helpful? 3
  • +
  • -

#3 izic  Icon User is offline

  • D.I.C Head

Reputation: -2
  • View blog
  • Posts: 197
  • Joined: 15-January 09

Re: Having a string of numbers display on click.

Posted 23 September 2012 - 07:42 AM

View PostEndLessMind, on 23 September 2012 - 03:12 AM, said:

Every time you cal setText(); the old value is overwritten.
Try using calculations.setText(calculations.getText() + text);


I tried using that but now I'm getting a "the operator + is undefined for the argument type editable char sequence" error. Should I remove
CharSequence text= one.getText();
and change it to
text= two.getText();
?
Was This Post Helpful? 0
  • +
  • -

#4 kabuto178  Icon User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 130
  • Joined: 29-January 11

Re: Having a string of numbers display on click.

Posted 23 September 2012 - 07:57 AM

maybe you need to cast the text that you entered as int then you carry out the operation, then set the text to the result. have not tried it but just a suggestion
Was This Post Helpful? 0
  • +
  • -

#5 EndLessMind  Icon User is offline

  • These are the droids you're looking for
  • member icon

Reputation: 194
  • View blog
  • Posts: 1,099
  • Joined: 13-March 09

Re: Having a string of numbers display on click.

Posted 23 September 2012 - 08:25 AM

Sorry, missed that.
That's because text is a CharSequence and getText() returns a String.
That's different types of value and can't be added together without conversion.
toString() will to that for you.

To the correct code would be calculations.setText(calculations.getText() + text.toString());
Was This Post Helpful? 1
  • +
  • -

#6 izic  Icon User is offline

  • D.I.C Head

Reputation: -2
  • View blog
  • Posts: 197
  • Joined: 15-January 09

Re: Having a string of numbers display on click.

Posted 23 September 2012 - 09:31 AM

Thanks man, it worked. I know if I wanted to add two different numbers from two different Editexts it'll look something like this for example.

public void onAdditionclick(View view)
{ 
double answer=getValueOne()+ getValueTwo(); 
setAnswer(answer); 
} 


My question now is how would I go about adding two or more numbers in the same Editext and displaying the result in the same textbox?

Example:
http://i50.tinypic.com/dvpnco.png
Was This Post Helpful? 0
  • +
  • -

#7 EndLessMind  Icon User is offline

  • These are the droids you're looking for
  • member icon

Reputation: 194
  • View blog
  • Posts: 1,099
  • Joined: 13-March 09

Re: Having a string of numbers display on click.

Posted 23 September 2012 - 09:55 AM

Like, if you have and unknown number of values to add?
i.e : 4+3+2+...?
Was This Post Helpful? 0
  • +
  • -

#8 izic  Icon User is offline

  • D.I.C Head

Reputation: -2
  • View blog
  • Posts: 197
  • Joined: 15-January 09

Re: Having a string of numbers display on click.

Posted 23 September 2012 - 10:13 AM

Yeah, so it'll be like the user presses a number button and if the addition button is clicked, the previous number is cleared from the textbox and the new number is shown instead. If the user presses the equal button then both numbers are added up and the result is shown in the same box.
Was This Post Helpful? 0
  • +
  • -

#9 EndLessMind  Icon User is offline

  • These are the droids you're looking for
  • member icon

Reputation: 194
  • View blog
  • Posts: 1,099
  • Joined: 13-March 09

Re: Having a string of numbers display on click.

Posted 23 September 2012 - 11:00 AM

You'll need a list
private ArrayList<Integer> numbers;


Then, each time the "+"-button is pressed
numbers.add(Integer.parseInt(calculations.getText()));
calculations.clear();


When the equal-button is pressed:
int value = 0;
for (Integer i : numbers) {
value += i.intValue();
}
calculations.setText(value);



In the onCreate:
numbers = new ArrayList<Integer>();



and then the you cant to clear:
numbers.clear();
calculations.clear();



Something like that, written it from the top of my head.
So there might be some miss-spellings or something like that.
But basically, that's how you do it.
Was This Post Helpful? 1
  • +
  • -

#10 izic  Icon User is offline

  • D.I.C Head

Reputation: -2
  • View blog
  • Posts: 197
  • Joined: 15-January 09

Re: Having a string of numbers display on click.

Posted 23 September 2012 - 12:22 PM

Ah ok. I followed what you gave but the program seems to crash when I press equal.

int value = 0;
	for (Integer i : numbers) {
	value += i.intValue();
	}
calculations.setText(value);


Should the calculations.setText(value) part be converted to int since value is an integer?


package app.droidcalc; 

import java.util.ArrayList;

import app.droidcalc.R;
import android.app.Activity;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
import android.text.Editable;

public class DroidCalcActivity extends Activity 
{
    Button one, two, three, four, five, six, seven, 
    eight, nine, zero, clr, bksp, add, sub, mult, eql, deci, div;
    EditText calculations;
    private ArrayList<Integer>numbers;
    
    
	@Override 
	public void onCreate(Bundle savedInstanceState) 
	{ 
		super.onCreate(savedInstanceState); 
		setContentView(R.layout.main); 
		/*val1=(EditText) findViewById(R.id.edVal1); 
		val2=(EditText) findViewById(R.id.edVal2); 
		ans=(TextView) findViewById(R.id.tvAns );*/ 
		calculations=(EditText)findViewById(R.id.calc);
		one=(Button) findViewById(R.id.num1); 
		two=(Button)findViewById(R.id.num2); 
		three=(Button) findViewById(R.id.num3); 
		four=(Button) findViewById(R.id.num4); 
		five=(Button)findViewById(R.id.num5); 
		six=(Button) findViewById(R.id.num6); 
		seven=(Button) findViewById(R.id.num7); 
		eight=(Button)findViewById(R.id.num8); 
		nine=(Button) findViewById(R.id.num9); 
		zero=(Button) findViewById(R.id.button0);
		bksp=(Button) findViewById(R.id.backspace);
		clr=(Button) findViewById(R.id.clear);
		add=(Button) findViewById(R.id.addition);
		sub=(Button) findViewById(R.id.subtraction);
		mult=(Button) findViewById(R.id.multiplication);
		eql=(Button) findViewById(R.id.equalsign);
		deci=(Button) findViewById(R.id.buttonDecimal);
		div=(Button) findViewById(R.id.division);
		
		numbers = new ArrayList<Integer>();
		
		one.setonclickListener(new Button.onclickListener() {
	    @Override
		public void onclick(View v) 
	    {
	       
	    	CharSequence text= one.getText();
			calculations.setText(calculations.getText() + text.toString());		
		}
		});
		
		two.setonclickListener(new Button.onclickListener() {
		@Override
		public void onclick(View v) 
		{
			CharSequence text= two.getText();
			calculations.setText(calculations.getText() + text.toString());  	 
		}
		});
		
		three.setonclickListener(new Button.onclickListener() {
		public void onclick(View v) 
		{
			CharSequence text= three.getText();
			calculations.setText(calculations.getText() + text.toString());  	 
		}
		});

		four.setonclickListener(new Button.onclickListener() {
		public void onclick(View v) 
		{
			CharSequence text= four.getText();
			calculations.setText(calculations.getText() + text.toString());
		}
		});
		
		five.setonclickListener(new Button.onclickListener() {
		public void onclick(View v) 
		{
			CharSequence text= five.getText();
			calculations.setText(calculations.getText() + text.toString());  
		}
		});
		
		six.setonclickListener(new Button.onclickListener() {
		public void onclick(View v) 
		{
			CharSequence text= six.getText();
			calculations.setText(calculations.getText() + text.toString());  
		}
		});
		
		seven.setonclickListener(new Button.onclickListener() {
		public void onclick(View v) 
		{
			CharSequence text= seven.getText();
			calculations.setText(calculations.getText() + text.toString());      	 
		}
		});
		
		eight.setonclickListener(new Button.onclickListener() {
		public void onclick(View v) 
		{
			CharSequence text= eight.getText();
			calculations.setText(calculations.getText() + text.toString());      	 
		}
		});
		
		nine.setonclickListener(new Button.onclickListener() {
		public void onclick(View v) 
		{
			CharSequence text= nine.getText();
			calculations.setText(calculations.getText() + text.toString());    	 
		}
		});
		
		zero.setonclickListener(new Button.onclickListener() {
		public void onclick(View v) 
		{
			CharSequence text= zero.getText();
			calculations.setText(calculations.getText() + text.toString());      	 
		}
		});
		
		clr.setonclickListener(new Button.onclickListener(){
		public void onclick(View v)
		{
			EditText calculations=(EditText) findViewById(R.id.calc);
			calculations.setText(" ");
		}
		});	  
		
		deci.setonclickListener(new Button.onclickListener(){
		public void onclick(View v)
		{
			CharSequence text= deci.getText();
			calculations.setText(calculations.getText() + text.toString());
		}
		}); 
		
		bksp.setonclickListener(new Button.onclickListener(){
		@Override
		public void onclick(View v)
		{
			calculations.dispatchKeyEvent(new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_DEL));
		}
	    });
		
		add.setonclickListener(new Button.onclickListener(){
		@Override
		public void onclick(View v) {
			numbers.add(Integer.parseInt(calculations.getText().toString()));
			calculations.clearFocus(); 
		}
		});
		
		eql.setonclickListener(new Button.onclickListener(){
		@Override
		public void onclick(View v)
		{
			int value = 0;
			for (Integer i : numbers) 
			{
				value += i.intValue();
			}
			calculations.setText(value);
		}
		});
}
}

Was This Post Helpful? 0
  • +
  • -

#11 EndLessMind  Icon User is offline

  • These are the droids you're looking for
  • member icon

Reputation: 194
  • View blog
  • Posts: 1,099
  • Joined: 13-March 09

Re: Having a string of numbers display on click.

Posted 23 September 2012 - 01:57 PM

What dose the logcat say? It should give you as error.

No, calculations.setText(value); do not need to be converted.
The EditText want a String or a array or char's, but i can automatically convert
integer to string.
Also, "value" is an int, which is an simpler form of Integer.
We convert Integer to int by calling "intValue();"
Was This Post Helpful? 0
  • +
  • -

#12 izic  Icon User is offline

  • D.I.C Head

Reputation: -2
  • View blog
  • Posts: 197
  • Joined: 15-January 09

Re: Having a string of numbers display on click.

Posted 23 September 2012 - 02:32 PM

Logcat

09-23 19:18:52.116: ERROR/AndroidRuntime(546):     at android.view.View$PerformClick.run(View.java:8816)
09-23 19:18:52.116: ERROR/AndroidRuntime(546):     at android.os.Handler.handleCallback(Handler.java:587)
09-23 19:18:52.116: ERROR/AndroidRuntime(546):     at android.os.Handler.dispatchMessage(Handler.java:92)
09-23 19:18:52.116: ERROR/AndroidRuntime(546):     at android.os.Looper.loop(Looper.java:123)
09-23 19:18:52.116: ERROR/AndroidRuntime(546):     at android.app.ActivityThread.main(ActivityThread.java:4627)
09-23 19:18:52.116: ERROR/AndroidRuntime(546):     at java.lang.reflect.Method.invokeNative(Native Method)
09-23 19:18:52.116: ERROR/AndroidRuntime(546):     at java.lang.reflect.Method.invoke(Method.java:521)
09-23 19:18:52.116: ERROR/AndroidRuntime(546):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
09-23 19:18:52.116: ERROR/AndroidRuntime(546):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
09-23 19:18:52.116: ERROR/AndroidRuntime(546):     at dalvik.system.NativeStart.main(Native Method)
09-23 19:18:52.116: ERROR/AndroidRuntime(546): FATAL EXCEPTION: main
09-23 19:18:52.116: ERROR/AndroidRuntime(546): android.content.res.Resources$NotFoundException: String resource ID #0x4
09-23 19:18:52.116: ERROR/AndroidRuntime(546):     at android.content.res.Resources.getText(Resources.java:201)
09-23 19:18:52.116: ERROR/AndroidRuntime(546):     at android.widget.TextView.setText(TextView.java:2817)
09-23 19:18:52.116: ERROR/AndroidRuntime(546):     at app.droidcalc.DroidCalcActivity$15.onclick(DroidCalcActivity.java:179)
09-23 19:18:52.116: ERROR/AndroidRuntime(546):     at android.view.View.performClick(View.java:2408)
09-23 19:18:32.256: ERROR/AndroidRuntime(539): FATAL EXCEPTION: main
09-23 19:18:32.256: ERROR/AndroidRuntime(539): java.lang.NumberFormatException: unable to parse ' 1' as integer
09-23 19:18:32.256: ERROR/AndroidRuntime(539):     at java.lang.Integer.parse(Integer.java:433)
09-23 19:18:32.256: ERROR/AndroidRuntime(539):     at java.lang.Integer.parseInt(Integer.java:422)
09-23 19:18:32.256: ERROR/AndroidRuntime(539):     at java.lang.Integer.parseInt(Integer.java:382)
09-23 19:18:32.256: ERROR/AndroidRuntime(539):     at app.droidcalc.DroidCalcActivity$14.onclick(DroidCalcActivity.java:165)
09-23 19:18:32.256: ERROR/AndroidRuntime(539):     at android.view.View.performClick(View.java:2408)
09-23 19:18:32.256: ERROR/AndroidRuntime(539):     at android.view.View$PerformClick.run(View.java:8816)
09-23 19:18:32.256: ERROR/AndroidRuntime(539):     at android.os.Handler.handleCallback(Handler.java:587)
09-23 19:18:32.256: ERROR/AndroidRuntime(539):     at android.os.Handler.dispatchMessage(Handler.java:92)
09-23 19:18:32.256: ERROR/AndroidRuntime(539):     at android.os.Looper.loop(Looper.java:123)
09-23 19:18:32.256: ERROR/AndroidRuntime(539):     at android.app.ActivityThread.main(ActivityThread.java:4627)
09-23 19:18:32.256: ERROR/AndroidRuntime(539):     at java.lang.reflect.Method.invokeNative(Native Method)
09-23 19:18:32.256: ERROR/AndroidRuntime(539):     at java.lang.reflect.Method.invoke(Method.java:521)
09-23 19:18:32.256: ERROR/AndroidRuntime(539):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
09-23 19:18:32.256: ERROR/AndroidRuntime(539):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
09-23 19:18:32.256: ERROR/AndroidRuntime(539):     at dalvik.system.NativeStart.main(Native Method)
09-23 19:13:28.865: ERROR/AndroidRuntime(531): FATAL EXCEPTION: main
09-23 19:13:28.865: ERROR/AndroidRuntime(531): android.content.res.Resources$NotFoundException: String resource ID #0x8
09-23 19:13:28.865: ERROR/AndroidRuntime(531):     at android.content.res.Resources.getText(Resources.java:201)
09-23 19:13:28.865: ERROR/AndroidRuntime(531):     at android.widget.TextView.setText(TextView.java:2817)
09-23 19:13:28.865: ERROR/AndroidRuntime(531):     at app.droidcalc.DroidCalcActivity$15.onclick(DroidCalcActivity.java:179)
09-23 19:13:28.865: ERROR/AndroidRuntime(531):     at android.view.View.performClick(View.java:2408)
09-23 19:13:28.865: ERROR/AndroidRuntime(531):     at android.view.View$PerformClick.run(View.java:8816)
09-23 19:13:28.865: ERROR/AndroidRuntime(531):     at android.os.Handler.handleCallback(Handler.java:587)
09-23 19:13:28.865: ERROR/AndroidRuntime(531):     at android.os.Handler.dispatchMessage(Handler.java:92)
09-23 19:13:28.865: ERROR/AndroidRuntime(531):     at android.os.Looper.loop(Looper.java:123)
09-23 19:13:28.865: ERROR/AndroidRuntime(531):     at android.app.ActivityThread.main(ActivityThread.java:4627)
09-23 19:13:28.865: ERROR/AndroidRuntime(531):     at java.lang.reflect.Method.invokeNative(Native Method)
09-23 19:13:28.865: ERROR/AndroidRuntime(531):     at java.lang.reflect.Method.invoke(Method.java:521)
09-23 19:13:28.865: ERROR/AndroidRuntime(531):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
09-23 19:13:28.865: ERROR/AndroidRuntime(531):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
09-23 19:13:28.865: ERROR/AndroidRuntime(531):     at dalvik.system.NativeStart.main(Native Method)
09-23 19:11:48.238: ERROR/AndroidRuntime(524): FATAL EXCEPTION: main
09-23 19:11:48.238: ERROR/AndroidRuntime(524): android.content.res.Resources$NotFoundException: String resource ID #0x2c
09-23 19:11:48.238: ERROR/AndroidRuntime(524):     at android.content.res.Resources.getText(Resources.java:201)
09-23 19:11:48.238: ERROR/AndroidRuntime(524):     at android.widget.TextView.setText(TextView.java:2817)
09-23 19:11:48.238: ERROR/AndroidRuntime(524):     at app.droidcalc.DroidCalcActivity$15.onclick(DroidCalcActivity.java:179)
09-23 19:11:48.238: ERROR/AndroidRuntime(524):     at android.view.View.performClick(View.java:2408)
09-23 19:11:48.238: ERROR/AndroidRuntime(524):     at android.view.View$PerformClick.run(View.java:8816)
09-23 19:11:48.238: ERROR/AndroidRuntime(524):     at android.os.Handler.handleCallback(Handler.java:587)
09-23 19:11:48.238: ERROR/AndroidRuntime(524):     at android.os.Handler.dispatchMessage(Handler.java:92)
09-23 19:11:48.238: ERROR/AndroidRuntime(524):     at android.os.Looper.loop(Looper.java:123)
09-23 19:11:48.238: ERROR/AndroidRuntime(524):     at android.app.ActivityThread.main(ActivityThread.java:4627)
09-23 19:11:48.238: ERROR/AndroidRuntime(524):     at java.lang.reflect.Method.invokeNative(Native Method)
09-23 19:11:48.238: ERROR/AndroidRuntime(524):     at java.lang.reflect.Method.invoke(Method.java:521)
09-23 19:11:48.238: ERROR/AndroidRuntime(524):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
09-23 19:11:48.238: ERROR/AndroidRuntime(524):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
09-23 19:11:48.238: ERROR/AndroidRuntime(524):     at dalvik.system.NativeStart.main(Native Method)
09-23 19:11:33.226: ERROR/AndroidRuntime(517):     at android.view.View.performClick(View.java:2408)
09-23 19:11:33.226: ERROR/AndroidRuntime(517):     at android.view.View$PerformClick.run(View.java:8816)
09-23 19:11:33.226: ERROR/AndroidRuntime(517):     at android.os.Handler.handleCallback(Handler.java:587)
09-23 19:11:33.226: ERROR/AndroidRuntime(517):     at android.os.Handler.dispatchMessage(Handler.java:92)
09-23 19:11:33.226: ERROR/AndroidRuntime(517):     at android.os.Looper.loop(Looper.java:123)
09-23 19:11:33.226: ERROR/AndroidRuntime(517):     at android.app.ActivityThread.main(ActivityThread.java:4627)
09-23 19:11:33.226: ERROR/AndroidRuntime(517):     at java.lang.reflect.Method.invokeNative(Native Method)
09-23 19:11:33.226: ERROR/AndroidRuntime(517):     at java.lang.reflect.Method.invoke(Method.java:521)
09-23 19:11:33.226: ERROR/AndroidRuntime(517):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
09-23 19:11:33.226: ERROR/AndroidRuntime(517):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
09-23 19:11:33.226: ERROR/AndroidRuntime(517):     at dalvik.system.NativeStart.main(Native Method)
09-23 19:11:33.226: ERROR/AndroidRuntime(517):
 FATAL EXCEPTION: main
09-23 19:11:33.226: ERROR/AndroidRuntime(517): android.content.res.Resources$NotFoundException: String resource ID #0x7043
09-23 19:11:33.226: ERROR/AndroidRuntime(517):     at android.content.res.Resources.getText(Resources.java:201)
09-23 19:11:33.226: ERROR/AndroidRuntime(517):     at android.widget.TextView.setText(TextView.java:2817)
09-23 19:11:33.226: ERROR/AndroidRuntime(517):     at app.droidcalc.DroidCalcActivity$15.onclick(DroidCalcActivity.java:179)
09-23 19:11:10.626: ERROR/AndroidRuntime(510): FATAL EXCEPTION: main
09-23 19:11:10.626: ERROR/AndroidRuntime(510): android.content.res.Resources$NotFoundException: String resource ID #0x23
09-23 19:11:10.626: ERROR/AndroidRuntime(510):     at android.content.res.Resources.getText(Resources.java:201)
09-23 19:11:10.626: ERROR/AndroidRuntime(510):     at android.widget.TextView.setText(TextView.java:2817)
09-23 19:11:10.626: ERROR/AndroidRuntime(510):     at app.droidcalc.DroidCalcActivity$15.onclick(DroidCalcActivity.java:179)
09-23 19:11:10.626: ERROR/AndroidRuntime(510):     at android.view.View.performClick(View.java:2408)
09-23 19:11:10.626: ERROR/AndroidRuntime(510):     at android.view.View$PerformClick.run(View.java:8816)
09-23 19:11:10.626: ERROR/AndroidRuntime(510):     at android.os.Handler.handleCallback(Handler.java:587)
09-23 19:11:10.626: ERROR/AndroidRuntime(510):     at android.os.Handler.dispatchMessage(Handler.java:92)
09-23 19:11:10.626: ERROR/AndroidRuntime(510):     at android.os.Looper.loop(Looper.java:123)
09-23 19:11:10.626: ERROR/AndroidRuntime(510):     at android.app.ActivityThread.main(ActivityThread.java:4627)
09-23 19:11:10.626: ERROR/AndroidRuntime(510):     at java.lang.reflect.Method.invokeNative(Native Method)
09-23 19:11:10.626: ERROR/AndroidRuntime(510):     at java.lang.reflect.Method.invoke(Method.java:521)
09-23 19:11:10.626: ERROR/AndroidRuntime(510):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
09-23 19:11:10.626: ERROR/AndroidRuntime(510):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
09-23 19:11:10.626: ERROR/AndroidRuntime(510):     at dalvik.system.NativeStart.main(Native Method)
09-23 19:06:46.108: ERROR/AndroidRuntime(495): FATAL EXCEPTION: main
09-23 19:06:46.108: ERROR/AndroidRuntime(495): android.content.res.Resources$NotFoundException: String resource ID #0x7547
09-23 19:06:46.108: ERROR/AndroidRuntime(495):     at android.content.res.Resources.getText(Resources.java:201)
09-23 19:06:46.108: ERROR/AndroidRuntime(495):     at android.widget.TextView.setText(TextView.java:2817)
09-23 19:06:46.108: ERROR/AndroidRuntime(495):     at app.droidcalc.DroidCalcActivity$15.onclick(DroidCalcActivity.java:179)
09-23 19:06:46.108: ERROR/AndroidRuntime(495):     at android.view.View.performClick(View.java:2408)
09-23 19:06:46.108: ERROR/AndroidRuntime(495):     at android.view.View$PerformClick.run(View.java:8816)
09-23 19:06:46.108: ERROR/AndroidRuntime(495):     at android.os.Handler.handleCallback(Handler.java:587)
09-23 19:06:46.108: ERROR/AndroidRuntime(495):     at android.os.Handler.dispatchMessage(Handler.java:92)
09-23 19:06:46.108: ERROR/AndroidRuntime(495):     at android.os.Looper.loop(Looper.java:123)
09-23 19:06:46.108: ERROR/AndroidRuntime(495):     at android.app.ActivityThread.main(ActivityThread.java:4627)
09-23 19:06:46.108: ERROR/AndroidRuntime(495):     at java.lang.reflect.Method.invokeNative(Native Method)
09-23 19:06:46.108: ERROR/AndroidRuntime(495):     at java.lang.reflect.Method.invoke(Method.java:521)
09-23 19:06:46.108: ERROR/AndroidRuntime(495):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
09-23 19:06:46.108: ERROR/AndroidRuntime(495):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
09-23 19:06:46.108: ERROR/AndroidRuntime(495):     at dalvik.system.NativeStart.main(Native Method)
09-23 19:06:13.106: ERROR/AndroidRuntime(488): FATAL EXCEPTION: main
09-23 19:06:13.106: ERROR/AndroidRuntime(488): java.lang.NumberFormatException: unable to parse ' 8' as integer
09-23 19:06:13.106: ERROR/AndroidRuntime(488):     at java.lang.Integer.parse(Integer.java:433)
09-23 19:06:13.106: ERROR/AndroidRuntime(488):     at java.lang.Integer.parseInt(Integer.java:422)
09-23 19:06:13.106: ERROR/AndroidRuntime(488):     at java.lang.Integer.parseInt(Integer.java:382)
09-23 19:06:13.106: ERROR/AndroidRuntime(488):     at app.droidcalc.DroidCalcActivity$14.onclick(DroidCalcActivity.java:165)
09-23 19:06:13.106: ERROR/AndroidRuntime(488):     at android.view.View.performClick(View.java:2408)
09-23 19:06:13.106: ERROR/AndroidRuntime(488):     at android.view.View$PerformClick.run(View.java:8816)
09-23 19:06:13.106: ERROR/AndroidRuntime(488):     at android.os.Handler.handleCallback(Handler.java:587)
09-23 19:06:13.106: ERROR/AndroidRuntime(488):     at android.os.Handler.dispatchMessage(Handler.java:92)
09-23 19:06:13.106: ERROR/AndroidRuntime(488):     at android.os.Looper.loop(Looper.java:123)
09-23 19:06:13.106: ERROR/AndroidRuntime(488):     at android.app.ActivityThread.main(ActivityThread.java:4627)
09-23 19:06:13.106: ERROR/AndroidRuntime(488):     at java.lang.reflect.Method.invokeNative(Native Method)
09-23 19:06:13.106: ERROR/AndroidRuntime(488):     at java.lang.reflect.Method.invoke(Method.java:521)
09-23 19:06:13.106: ERROR/AndroidRuntime(488):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
09-23 19:06:13.106: ERROR/AndroidRuntime(488):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
09-23 19:06:13.106: ERROR/AndroidRuntime(488):     at dalvik.system.NativeStart.main(Native Method)
9-23 19:01:28.215: ERROR/AndroidRuntime(428): FATAL EXCEPTION: main
09-23 19:01:28.215: ERROR/AndroidRuntime(428): java.lang.NumberFormatException: unable to parse ' 777' as integer
09-23 19:01:28.215: ERROR/AndroidRuntime(428):     at java.lang.Integer.parse(Integer.java:433)
09-23 19:01:28.215: ERROR/AndroidRuntime(428):     at java.lang.Integer.parseInt(Integer.java:422)
09-23 19:01:28.215: ERROR/AndroidRuntime(428):     at java.lang.Integer.parseInt(Integer.java:382)
09-23 19:01:28.215: ERROR/AndroidRuntime(428):     at app.droidcalc.DroidCalcActivity$14.onclick(DroidCalcActivity.java:165)
09-23 19:01:28.215: ERROR/AndroidRuntime(428):     at android.view.View.performClick(View.java:2408)
09-23 19:01:28.215: ERROR/AndroidRuntime(428):     at android.view.View$PerformClick.run(View.java:8816)
09-23 19:01:28.215: ERROR/AndroidRuntime(428):     at android.os.Handler.handleCallback(Handler.java:587)
09-23 19:01:28.215: ERROR/AndroidRuntime(428):     at android.os.Handler.dispatchMessage(Handler.java:92)
09-23 19:01:28.215: ERROR/AndroidRuntime(428):     at android.os.Looper.loop(Looper.java:123)
09-23 19:01:28.215: ERROR/AndroidRuntime(428):     at android.app.ActivityThread.main(ActivityThread.java:4627)
09-23 19:01:28.215: ERROR/AndroidRuntime(428):     at java.lang.reflect.Method.invokeNative(Native Method)
09-23 19:01:28.215: ERROR/AndroidRuntime(428):     at java.lang.reflect.Method.invoke(Method.java:521)
09-23 19:01:28.215: ERROR/AndroidRuntime(428):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
09-23 19:01:28.215: ERROR/AndroidRuntime(428):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
09-23 19:01:28.215: ERROR/AndroidRuntime(428):     at dalvik.system.NativeStart.main(Native Method)
09-23 19:01:52.095: ERROR/AndroidRuntime(435): FATAL EXCEPTION: main
09-23 19:01:52.095: ERROR/AndroidRuntime(435): android.content.res.Resources$NotFoundException: String resource ID #0xc
09-23 19:01:52.095: ERROR/AndroidRuntime(435):     at android.content.res.Resources.getText(Resources.java:201)
09-23 19:01:52.095: ERROR/AndroidRuntime(435):     at android.widget.TextView.setText(TextView.java:2817)
09-23 19:01:52.095: ERROR/AndroidRuntime(435):  
   at app.droidcalc.DroidCalcActivity$15.onclick(DroidCalcActivity.java:179)
09-23 19:01:52.095: ERROR/AndroidRuntime(435):     at android.view.View.performClick(View.java:2408)
09-23 19:01:52.095: ERROR/AndroidRuntime(435):     at android.view.View$PerformClick.run(View.java:8816)
09-23 19:01:52.095: ERROR/AndroidRuntime(435):     at android.os.Handler.handleCallback(Handler.java:587)
09-23 19:01:52.095: ERROR/AndroidRuntime(435):     at android.os.Handler.dispatchMessage(Handler.java:92)
09-23 19:01:52.095: ERROR/AndroidRuntime(435):     at android.os.Looper.loop(Looper.java:123)
09-23 19:01:52.095: ERROR/AndroidRuntime(435):     at android.app.ActivityThread.main(ActivityThread.java:4627)
09-23 19:01:52.095: ERROR/AndroidRuntime(435):     at java.lang.reflect.Method.invokeNative(Native Method)
09-23 19:01:52.095: ERROR/AndroidRuntime(435):     at java.lang.reflect.Method.invoke(Method.java:521)
09-23 19:01:52.095: ERROR/AndroidRuntime(435):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
09-23 19:01:52.095: ERROR/AndroidRuntime(435):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
09-23 19:01:52.095: ERROR/AndroidRuntime(435):     at dalvik.system.NativeStart.main(Native Method)

09-23 18:38:31.716: ERROR/AndroidRuntime(399): FATAL EXCEPTION: main
09-23 18:38:31.716: ERROR/AndroidRuntime(399): android.content.res.Resources$NotFoundException: String resource ID #0x0
09-23 18:38:31.716: ERROR/AndroidRuntime(399):     at android.content.res.Resources.getText(Resources.java:201)
09-23 18:38:31.716: ERROR/AndroidRuntime(399):     at android.widget.TextView.setText(TextView.java:2817)
09-23 18:38:31.716: ERROR/AndroidRuntime(399):     at app.droidcalc.DroidCalcActivity$15.onclick(DroidCalcActivity.java:180)
09-23 18:38:31.716: ERROR/AndroidRuntime(399):     at android.view.View.performClick(View.java:2408)
09-23 18:38:31.716: ERROR/AndroidRuntime(399):     at android.view.View$PerformClick.run(View.java:8816)
09-23 18:38:31.716: ERROR/AndroidRuntime(399):     at android.os.Handler.handleCallback(Handler.java:587)
09-23 18:38:31.716: ERROR/AndroidRuntime(399):     at android.os.Handler.dispatchMessage(Handler.java:92)
09-23 18:38:31.716: ERROR/AndroidRuntime(399):     at android.os.Looper.loop(Looper.java:123)
09-23 18:38:31.716: ERROR/AndroidRuntime(399):     at android.app.ActivityThread.main(ActivityThread.java:4627)
09-23 18:38:31.716: ERROR/AndroidRuntime(399):     at java.lang.reflect.Method.invokeNative(Native Method)
09-23 18:38:31.716: ERROR/AndroidRuntime(399):     at java.lang.reflect.Method.invoke(Method.java:521)
09-23 18:38:31.716: ERROR/AndroidRuntime(399):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
09-23 18:38:31.716: ERROR/AndroidRuntime(399):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
09-23 18:38:31.716: ERROR/AndroidRuntime(399):     at dalvik.system.NativeStart.main(Native Method)

Was This Post Helpful? 0
  • +
  • -

#13 EndLessMind  Icon User is offline

  • These are the droids you're looking for
  • member icon

Reputation: 194
  • View blog
  • Posts: 1,099
  • Joined: 13-March 09

Re: Having a string of numbers display on click.

Posted 23 September 2012 - 04:13 PM

Try change "clearFocus();" to just "clear();"
in the "add.setonclickListener"
Was This Post Helpful? 0
  • +
  • -

#14 izic  Icon User is offline

  • D.I.C Head

Reputation: -2
  • View blog
  • Posts: 197
  • Joined: 15-January 09

Re: Having a string of numbers display on click.

Posted 23 September 2012 - 05:58 PM

View PostEndLessMind, on 23 September 2012 - 07:13 PM, said:

Try change "clearFocus();" to just "clear();"
in the "add.setonclickListener"


I did but I get a "The method clear() is undefined for the type EditText" error message.
Was This Post Helpful? 0
  • +
  • -

#15 EndLessMind  Icon User is offline

  • These are the droids you're looking for
  • member icon

Reputation: 194
  • View blog
  • Posts: 1,099
  • Joined: 13-March 09

Re: Having a string of numbers display on click.

Posted 24 September 2012 - 01:33 AM

Oh, right. The the AutoCompleteTextView i'm thinking of.
The just use "setText("");"
Was This Post Helpful? 1
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2