Hi all, I'm new to android development. I have some experience with Java but nothing when it comes to xml. I'm making the second application the book I'm using is instructing which is a silent mode toggle. However, I can't get my main layout working properly. Code (Text): <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" > <ImageView android:id="@+id/phone_icon" android:layout_width=
Sometime, just sometimes, the SDK throws a wobbly and needs restarting, as It's the only way I've found to solve this issue when I've encountered it myself. Another problem can occur when code is copyed and paste from another program like gedit, open office, etc, and found that cuuting ALL the code out and manualy re-entering it works because it removes any errant line feeds, carriage returns or other no-printing characters. What do you mean when you mention the setup of your png's? which directory have you placed them in? have you been editing the png's in a program and saved as a png without being converted to the png format? Hope this helps. GIR
How do I restart the SDK? I manually enterred all the code myself the first time and tried playing around or copying and pasting other code for about an hour trying to get this to stop throwing the error with no luck. I was thinking just the setup of all the images I was using might not have been done right since I took a shortcut not wanting to make different sized images for each resolution since this is only my second android app ever and I won't really be using it other than for learning purposes. I took all my pngs from the web that fell under the requirements the book listed. I have one for the icon, and two for images to show depending on the current mode of the phone (on or silent). These were place in the drawable folders but I used the same three images in ldpi, mdpi and hdpi. Thanks for the help!
This is my third day trying to get this working, I've closed and reopenned Eclipse many times I added the '+' in android:id=
Glad to be of help, don't forget there is a 'thanks' button I have found your problem, the quotes used after the line Code (Text): <ImageView android:id="@+id/phone_icon" are in a different encoding. To fix simple delete ALL you quote marks and manually re-enter them. I only found the problem after copying your xml file into eclipse and seeing for myself. Code after replacement = Code (Text): <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" > <ImageView android:id="@+id/phone_icon" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_horizontal" android:src="@drawable/phone_on" /> <Button android:id="@id/toggleButton" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_horizontal" android:text="Toggle Silent Mode" /> </LinearLayout> Simply copy and paste this into your xml file and all will be well. It has to be said that this is one danger of copying code from websites - when you copy them your pc also grabs the encoding info along with it (as described in whatever sites html files) - and when its pasted back into eclipse the encoding is also embedded . Hop ethis helps, GIR
How did you figure this out? Is there a way to see the encoding in Eclipse? What does that really mean, different encoding? So helpful, thanks so much. You have no idea how close I was to giving up. What's strange is that I thought I wrote most of the code manually. All that time trying to play around with it must have gotten to my head. The book I'm using is a pdf so I assume the same thing about the encoding applies there too. I'll make sure to be extra careful when copying text in the future.
For more information about encoding take a look here : The Definitive Guide to Web Character Encoding
Thank you SO much DavidSimon for discussing this problem over here. I myself was facing the exact same problem in Eclipse. I am pretty sure you are reading the same "PDF book" that I am using to learn Android Development and I did the same thing : copying and pasting the code to eclipse. My app works now! And Thanks to you GIR for finding the solution for these errors. Because of you I am able to continue programming. Really, thanks a lot!