Yes, you are right. I have changed the id="@+id... to android:id="@ +id. It works. Thank you!
On 5月6日, 下午1时47分, "Dan U." <[EMAIL PROTECTED]> wrote: > > What is timestamp of this xml file? How does it work with the app? > > I think the reason it was suggested was to convince the thing to > recompile. I don't think that's the problem. I'd guess you are using > the m5 sdk, but the layout file you posted is m3. try changing the > id="@+id... to android:id="@+id... > > On May 5, 8:22 pm, tagore <[EMAIL PROTECTED]> wrote: > > > Thank you for your reply. > > > the relative_view.xml file is shown below: > > <?xml version="1.0" encoding="UTF-8"?> > > <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/ > > android" > > android:layout_width="fill_parent" > > android:layout_height="wrap_content" > > android:padding="10px"> > > > <TextView id="@+id/label" > > android:layout_width="fill_parent" > > android:layout_height="wrap_content" > > android:text="Type here:"/> > > > <EditText id="@+id/entry" > > android:layout_width="fill_parent" > > android:layout_height="wrap_content" > > android:background="@android:drawable/ > > editbox_background" > > android:layout_below="@id/label"/> > > > <Button id="@+id/ok" > > android:layout_width="wrap_content" > > android:layout_height="wrap_content" > > android:layout_below="@id/entry" > > android:layout_alignParentRight="true" > > android:layout_marginLeft="10px" > > android:text="OK" /> > > > <Button android:layout_width="wrap_content" > > android:layout_height="wrap_content" > > android:layout_toLeft="@id/ok" > > android:layout_alignTop="@id/ok" > > android:text="Cancel" /> > > </RelativeLayout> > > > I REALLY have the id -- entry. I wonder if there is other problem? > > What is timestamp of this xml file? How does it work with the app? > > > On 5月6日, 上午10时04分, Mark Murphy <[EMAIL PROTECTED]> wrote: > > > > tagore wrote: > > > > Today, I write some simple code to implement activity. See the > > > > following codes: > > > > public class TestLinearView extends Activity { > > > > private EditText edit = null; > > > > /** Called when the activity is first created. */ > > > > @Override > > > > public void onCreate(Bundle icicle) { > > > > super.onCreate(icicle); > > > > > // Set activity content from layout view > > > > setContentView(R.layout.relative_view); > > > > > // change the edit text > > > > edit = (EditText)findViewById(R.id.entry); > > > > edit.setText("Mysdfsadfdsafdsf"); > > > > } > > > > } > > > > > However, the application crushed. After I debug into the app, I found > > > > that the edit was null. > > > > It would appear that your res/layout/relative_view.xml file does not > > > have a view with the id of "@+id/entry". I would have expected a > > > compiler error, though, complaining that R.id.entry was not found. > > > Perhaps your R.java file is out of sync with the contents of your res/ > > > directory tree. > > > > Try updating the timestamp on your res/layout/relative_view.xml file > > > (e.g., touch res/layout/relative_view.xml in Linux) and recompile. Or, > > > update res/layout/relative_view.xml to include an EditText element with > > > an android:id of "@+id/entry", since it would appear it doesn't have one > > > already. > > > > -- > > > Mark Murphy (a Commons Guy)http://commonsware.com > > > The Busy Coder's Guide to Android Development -- coming in June 2008! --~--~---------~--~----~------------~-------~--~----~ 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] Announcing the new M5 SDK! http://android-developers.blogspot.com/2008/02/android-sdk-m5-rc14-now-available.html For more options, visit this group at http://groups.google.com/group/android-beginners?hl=en -~----------~----~----~----~------~----~------~--~---

