-1

Well as the title states, anytime I try (in my java class) to settext of a TextView by directing it set the text of a string listed in "strings.xml" my program crashes, If i remove that call then the program runs fine. Below is an example.

    MediaPlayer dus;
String Stat;

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    setContentView(R.layout.main);
    final TextView T = (TextView) findViewById(R.id.Status);
    dus = MediaPlayer.create(DialUpDroidActivity.this, R.raw.dus);
    Timer timer;
    timer = new Timer();
    dus.start();
    Stat = getString(R.string.Dial);

    TimerTask TxtTimer = new TimerTask() {
        public void run() {
            T.setText(Stat);
        }
    };
    timer.schedule(TxtTimer, 7000);

}

So as you can see i tried to do T.setText(Stat); but the program crashed. I've tried T.setTextView(R.string.Dial); and T.setTextView("Hello") Both methods crashed. What am I doing wrong?

n0denine
  • 341
  • 2
  • 11

2 Answers2

0

Have you initiliazed your textview?

TextView T = (TextView)findViewById(R.id.yourId);
Jayp
  • 782
  • 2
  • 6
  • 21
  • Yes I have, the code that I posts was rewritten in after multiple ways of trying to do what I was trying to do. – n0denine Jul 28 '11 at 18:57
0

Where is

T = (TextView)findById(...)

? Use

getString(R.string.XXX)
TOX
  • 1