1. Check out our companion app, Forums for Android! Download from Google Play

Problem when running XML file

Discussion in 'Application Development' started by pazvanti, Jun 30, 2010.

  1. pazvanti

    pazvanti New Member
    Thread Starter

    Jun 17, 2010
    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


  2. markb

    markb Well-Known Member

    Sep 14, 2009
    Software Developer (Java, C, Web, Unix)
    Birmingham, UK
    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.

    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 (Text):
    2. View - android.view
    3. ViewAnimator - android.widget
    4. ViewAserts - android.test
    5. 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.

    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.

  3. pazvanti

    pazvanti New Member
    Thread Starter

    Jun 17, 2010
    Thanks for the reply. Everything is OK now.

Share This Page