Lovedumplingx wrote:
> So I see the NullPointer Exception as a good starting point but I'm
> still perplexed.
>
> I created a new project just for testing. And I can't get this to
> work:
>
> package com.test;
>
> import android.app.Activity;
> import android.os.Bundle;
> import android.widget.EditText;
>
> public class main extends Activity {
> /** Called when the activity is first created. */
> EditText justFillIn;
>
> @Override
> public void onCreate(Bundle savedInstanceState) {
> super.onCreate(savedInstanceState);
>
> justFillIn = (EditText) findViewById(R.id.ipText);
> justFillIn.setText("charSequence is a string");
>
> setContentView(R.layout.main);
> }
> }
>
> All I want to do is set the value for that EditText and it's just not
> working.
You must call setContentView() first.
You aren't telling Android what layout to display until you call
setContentView(). Hence, until that time, findViewById() is guaranteed
not to work, because there are no views to find.
--
Mark Murphy (a Commons Guy)
http://commonsware.com
Android App Developer Books: http://commonsware.com/books.html
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en
-~----------~----~----~----~------~----~------~--~---