• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Problem when running XML file

I am just starting with Android Development and have a few minor problems.
First of all, sometimes I don't always know what packages to import. Is there a way to import them automatically? I am coding in Ecplise.
2nd, If, because I am not attentive, I hit the "Run" button but with an XML file opened. This results in making a another xml file name <filename>.out.xml that has errors. If I delete the file I still have a red x on my project folder. And when I try to run the actual java file it sais that the project contains error. The only solution is to delete the entire project and recreate it. But this is uncovinient to always recreate the project, recopy the entire code and everything. Does anyone know how to solve this problem? Thanks
 
Hi pazvanti,

Welcome to Android development.

Eclipse is very powerful, but there is a bit of a learning curve.
I've been using it at work for about 7 years, and I'm sure there's an awful lot of features I still haven't learned about yet.

First of all, sometimes I don't always know what packages to import. Is there a way to import them automatically?

I don't bother remembering all the package names. I let Eclipse do it for me.
The first time I need to use a class that requires an import I type the class name and then type CTRL+SPACE - Eclipse then shows a pop-up list of classes that match.

For example, typing View (then ctrl+space) gives me a list that starts
Code:
View - android.view
ViewAnimator - android.widget
ViewAserts - android.test
etc...

You then pick the one you want, and Eclipse will add the import statement for you.
It's handy too if you can't quite remember the name of class. Type the start of the class name and let Eclipse suggest possible matches.

Ctrl+space comes in handy in other places too. When you want to call a method on an object Eclipse will list the methods for you if you press ctrl+space after you type the ".", or after you type the start of a method name.

Once you start using it you'll wonder how you managed without it.

If I delete the file I still have a red x on my project folder. And when I try to run the actual java file it sais that the project contains error. The only solution is to delete the entire project and recreate it.

You should be able to get rid of those error markers by forcing Eclipse to re-build the project. You can do that by choosing "Clean..." from the Project menu.

Mark
 
Upvote 0

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones