views:

101

answers:

3

Hi folks,

I have just started with Android with the usual Hello World project template in Eclipse. I modified the layout XML and removed the label that says "Hello World, !", and added a couple of other controls. However, these are not reflected in the app, within the emulator. When I run this app from Eclipse again it is still showing the Hello World label!

I'm sure it's something terribly simple that I have completely missed. Can someone please point me in the right direction?

Many thanks, Dany.

+1  A: 

Beginning Android Development


http://www.vogella.de/articles/Android/article.html

  • Checkout Sections 2.4 and 3.6 of the Tutorial

NOTE: In case U haven't downloaded it yet, get the SDK here:

http://developer.android.com/sdk/index.html

GoodLUCK!!

CVS-2600Hertz
+1  A: 

Try the following fixes in roughly the order I'm prescribing.

  • Make sure you saved the layout. If it wasn't saved, that would certainly do it.

  • Take a look at the xml itself, click on the small xml tab placed at the bottom of your layout. If you want to make the xml more easily readable, press Ctrl-Shift f if you're on windows. Does it look like what you'd expect?

  • For the controls, start by placing a linear layout, and make sure that the controls are placed within the linear layout. To make sure the controls are properly nested, use the Outline View, or better yet, just edit the xml file itself.

  • Clean your code (this deletes the generated files and rebuilds the project). In Eclipse, it's under the Project > Clean... (I think)

  • Make sure all the other projects are closed so that they do not interfere with the current project you might be working on. For all I know, you might be compiling the wrong one.

  • When you say you removed the label, did you click inside the textlabel and just change the wording? If so, that only changed the id/name of the label not the string inside the label. To change the string inside the textlabel, use the Properties View to do that.

  • To make sure you're looking at the right instance of the emulator. Close your emulator before running the project again (this is not normally advised for speed reasons, but in this case, I just want to check that the new emulator is even launching correctly). And by the way, when you say emulator, I hope that you're not confusing it with the what-you-see-is-what-you-get editor.

  • If that still doesn't work, go to the gen folder (generated files). Open the R.java file. Click inside, add a line return. And rebuild your project. I know this one sounds like a weird fix, but this fix does work from time to time.

  • Also, take a look at the Problems View, does it list a problem? And look at the Console when you're rerunning the code. What does the Console say?

Hope this helped. If this still doesn't work, I can always suggest more ways to debug your app.

Stephan Branczyk
Hi there, I have done the first 5 points you mentioned. There's only the 1 project in my workspace. I am a .NET dev used to working with WPF, so instinctively went straight to the XML. I deleted the label control completely, not just changing attributes.I haven't tried your 2nd-to-last-point but I see how that can work. I imagine upon build the R class is refreshed/regenerated? Then again, I'm not sure what you mean by build? I thought Eclipse continuously builds or something like that everytime I save the XML?
DanyW
There was nothing in the Problems View. And yeah, I didn't confuse the emulator with the "designer" view of the XML.I finally tried it using a new device created in AVD Manager and it reflected the changes. I'm still none the wiser thought...
DanyW
Yes, Eclipse is supposed to rebuild every time you save. And yes, I've run into weird problems like that before. Android/Eclipse can really be quirky sometimes.
Stephan Branczyk
+1  A: 

Edit your question and show us your XML file - you probably forgot to change the line android:text="@string/hello" but I'd be able to tell you for sure if I saw the file. Alternatively, you might not have changed the value for the string "hello" - to do that, go to "values" folder in the project directory, then edit strings.xml.

Steve H