The setText() method returns null in my application why?
public class GetValue extends Activity {
char letter = 'g';
int ascii = letter;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
TextView textView = (TextView)findViewById(R.id.txt_1);
textView.setText(ascii);
}
}
It doesn't matter what text i put in, it crashes anyway. Why does setText() keep returning null?
Thank you, in advance
Solution: My error was in the xml file. I wrote: android:text="@+id/txt_1" When it should say: android:id="@+id/txt_1"
Thanks a lot for all the answers and comments!