First off, i’ll post a picture to make it easier for you guys to understand.

As you can see, there’s an EditText and a button.
I want the button to save the contents of the EditText into a string + start a new activity.
In the next activity, i then want to convert the string into an Integer.
This is my current code:
SENDER ACTIVITY
startscore = (EditText) findViewById(R.id.startscore);
proceed = (Button) findViewById(R.id.bProceed);
proceed.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
Intent myIntent = new Intent(Introscreen.this, BillardScoreboardActivity.class);
String s = startscore.getText().toString();
Bundle b = new Bundle();
b.putString("lol", s);
//put into your intent
myIntent.putExtras(b);
Introscreen.this.startActivity(myIntent);
}
});
}
RECEIVER ACTIVITY
int counter1, counter2, counter3, counter4, counter5;
oncreate.....{
Bundle b = getIntent().getExtras();
String s = b.getString("lol");
column1tv = (TextView) findViewById(R.id.column1text);
column2tv = (TextView) findViewById(R.id.column2text);
column3tv = (TextView) findViewById(R.id.column3text);
column4tv = (TextView) findViewById(R.id.column4text);
column5tv = (TextView) findViewById(R.id.column5text);
column1tv.setText(counter1);
column2tv.setText(counter2);
column3tv.setText(counter3);
column4tv.setText(counter4);
column5tv.setText(counter5);
Hope you can help me troubleshooting it, to figure out the problem.
The problem:
Upon clicking the button, it shuts down the application and gives me those error codes:
02-23 15:01:24.136: E/AndroidRuntime(295): FATAL EXCEPTION: main
java.lang.RuntimeException: Unable to start activity
ComponentInfo{inno.games/inno.games.BillardScoreboardActivity}:
java.lang.NumberFormatException: unable to parse '' as integer
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
at android.app.ActivityThread.access$2300(ActivityThread.java:125)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:123)
at android.app.ActivityThread.main(ActivityThread.java:4627)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:521)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NumberFormatException: unable to parse '' as integer
at java.lang.Integer.parseInt(Integer.java:412)
at java.lang.Integer.parseInt(Integer.java:382)
at inno.games.BillardScoreboardActivity.onCreate(BillardScoreboardActivity.java:35)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
... 11 more

It’s breaking while trying to convert an empty string to an integer. Something is wrong while passing your string to the next activity. Try passing your string extra through a bundle instead:
Then get it in your next activity:
You also do need to switch your declarations of your TextViews and when you set them. You can’t set them if they are not yet declared.
Edit: One more thing. I’m assuming you only want integers typed into that EditText. You should set the inputType on it, if you haven’t already.
Edit 2: Don’t feel retarded, we were all beginners at one point! Firstly, try using a bundle and see if what you type into your EditText is properly passed to the next activity.
Second, you set the
inputTypefor theEditTextin your XML file. Should be something likeandroid:inputType="number".The declarations are these lines:
You’re creating an object for your TextViews. Then, you set them here:
You must create and instantiate the object before you can do anything with it.
Edit 3:
Okay, from the screenshot you posted, I gathered the following:
First- You’re creating the objects
counter1, counter2, etc..but you’re never instantiating them with anything. Which is probably where you’re getting your latest exception.Second- You’re getting the warning on the
String s = b.getString("lol");because it’s an unused local variable. (Check the problems tab in Eclipse and you’ll see what the warnings/problems you have in your code). You’re not doing anything with the string value that was passed from the previous activity.