Jump to content
Android Forum - A Community For Android Users and Enthusiasts

Display Integer variables in TextView?


Recommended Posts

Hey guys,

 

I'm completely new to Android programming, but I do have experience with Java programming. I'm trying to learn some of the basics by writing a very basic calorie counter. Here's the code I'm working with:

 

public class CalorieCounterActivity extends Activity {
/** Called when the activity is first created. */

private Integer totalCal = 2000;
private Integer remainingCal = 2000;

@Override
public void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	setContentView(R.layout.main);

	TextView totalCal = (TextView) findViewById(R.id.totalCal);
	totalCal.setText("\n\n\nCalories Allowed\n" + totalCal);

	TextView remainingCal = (TextView) findViewById(R.id.calRemain);
	remainingCal.setText("\n\n\nCalories Remaining\n" + remainingCal);
}
}

 

The problem is that when I run the app, the text in the textviews show up correctly, but the variables do not. I get the text: [email protected]

 

What am I doing incorrectly, and how do I fix it.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...