Go Back   Android Forums > Android Forums Community > The Lounge > Computers & IT

test: Reply
LinkBack Thread Tools
Old December 9th, 2012, 04:16 AM   #1 (permalink)
New Member
Thread Author (OP)
Join Date: Dec 2012
Location: Bryanston, Gauteng, South Africa
Gender: Male
Posts: 5
Carrier: Not Provided

Thanks: 1
Thanked 0 Times in 0 Posts
Cry setText on Button Click Crashes APP?

Hi there. I am trying to set the Text of a Text View when a button is clicked.

I have been struggling, because the variable will increment, but If i put the code in to set the text, it crashes the app ?

Here is my code when it crashes:

package com.example.test;

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

public class Game extends Activity{

Button spam;
TextView timeleft, score;
public int points = 0;
public int finalscore = 0;

protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub

spam = (Button) findViewById(R.id.gameSpamButton);
timeleft = (TextView) findViewById(R.id.gameTimeLeftTextView);
score = (TextView) findViewById(R.id.gameScoreTextView);

spam.setOnClickListener(new View.OnClickListener() {

public void onClick(View v) {
// TODO Auto-generated method stub
score.setText(points); // this is the line that crashes the app
however if I comment out the line
, the app doesnt crash, but it doesnt do anything then.

Please can someone help me!

VaMoose is offline  
Reply With Quote
sponsored links
Old December 9th, 2012, 07:09 AM   #2 (permalink)
ROM Developer
SUroot's Avatar
Join Date: May 2010
Location: Riddlesden, West Yorkshire, UK
Posts: 23,926
Device(s): SGS3 (Current) HTC Desire (Retired)
Carrier: 3 UK

Thanks: 1,923
Thanked 5,324 Times in 3,995 Posts

Are you developing an app? The development section would probably be a better place for this
SUroot is offline  
Reply With Quote
app, button, click, crash, event, onclick, settext, setting, text, textview

Go Back   Android Forums > Android Forums Community > The Lounge > Computers & IT
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 03:40 PM.
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.