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

Apps WTF?!?! How do I open res/layout/main.xml file?!?!

this stupid website(developer.adroid.com) is so vague! I'm in the resources section trying to do the Hello Views tutorial with the linear layout and it says:

1) Start a new project named HelloLinearLayout
2) Open the res/layout/main.xml file and insert the following: (xml code...)

ok so...I opened up Eclipse. File > New > Project. I named my new project HelloLinearLayout. Ok. Then how the heck do i "open the res/layout/main.xml file"??!?! I click Open and there is no "res/layout/main.xml" file. Please help!
 
I actually find the developer.android.com resource very good.

File > New > Android Project

If you don't have an Android Project item you didn't install the eclipse add-ons correct. The developers.android.com website describes how to do this in the Setting up the SDK section.


No no no no noooo, I have already the Android Project item! I just can't figure out how to open the "res/layout/main.xml file " and then be able to open the .java file of the source file which is HelloLinearLayout. Wtf I'm so confused. I know how to do Java, but this IDE is hella confusing.
 
Upvote 0
So you created an Android Project not a standard java project?
Try Window > Open Perspective > Java if you're not already on that Perspective.
Do you have the Package Explorer on the left hand side?
Then in Package Explorer on the right hand side open your project and open res and open layout and open main.xml

Maybe post a screenshot, sounds like you might have a weird layout or something.
 
Upvote 0
public​
class HelloRelativeLayout
{
public static void main(String[] args)
{
HelloRelativeLayout hrl = new HelloRelativeLayout();

hrl.onCreate();



}
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}

}​

Step two tells me(btw, I'm on relative layout now..I got fed up with linear..lol) to; "Make sure you load this layout in the onCreate() method: " and this is the code it gave me:

public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}


When i inserted this into my main, it gave me errors saying "The method onCreate() from the type HelloRelativeLayout refers to the missing type Bundle", and for the onCreate method, it says "Bundle cannot be resolved to a type" and inside the method it says "R cannot be resolved". What am I doing wrong? How can I fix this?

Here's the link to the page: Relative Layout | Android Developers
 
Upvote 0
Eclipse can have a bit of a learning curve, and be confusing at first.

Can I check that your eclipse looks something like the screen-shot below.
Do you have the Package Explorer panel shown at the left of the screen?
Can you see and open up the res & layout folders and see main.xml?

eclipse_res_layout.png


Mark
 
Upvote 0
Eclipse can have a bit of a learning curve, and be confusing at first.

Can I check that your eclipse looks something like the screen-shot below.
Do you have the Package Explorer panel shown at the left of the screen?
Can you see and open up the res & layout folders and see main.xml?

eclipse_res_layout.png


Mark

hmm, I don't have any of those folders(i only have the file name...which is HelloRelativeLayout.java, so maybe that's why?) in my package explorer....how did you get it to be able to have that res folder with drawable, layout, layout-land, raw, values, etc?
 
  • Like
Reactions: coder1
Upvote 0
in my package explorer....how did you get it to be able to have that res folder with drawable, layout, layout-land, raw, values, etc?

The res folder along with all the others are created for you automatically when you start a new Android project. That's why gorn asked earlier if you were sure you had created an Android project rather than a standard Java project. It sounds like you don't have an Android project.

Try following the instructions to create a new Android project to see what you get. You don't have to change anything you've already done, you can create another project just as a quick test.

Use File -> New -> Android Project...

Fill in the dialog box. The following screenshot is an example I used for someone else. Just for this test, try entering the same values to see what you get.

new_project.png


Then have a look in the Package Explorer to see what files and folders were automatically created. Compare that with what you have for your existing project.

Mark
 
  • Like
Reactions: Christophe2010
Upvote 0
everytime I try to start a new android project, it wont let me select a "SDK target"...and I've already add the SDK stuff to Eclipse but it just won't let me add or set my desired SDK target for the whole Eclipse program...:-/

I think it would have been helpful if you'd said that at the start.

Instead of this being a discussion about opening folders, it would have been about how to create a project and how to get the SDK set up correctly.

People did ask earlier if you were sure you had an Android project. That would have been a good time to mention your sdk selection problem.

I can't offer any more help at the moment as I'm away from my PC. (typing this on my nexus one, very slowly)
 
  • Like
Reactions: Christophe2010
Upvote 0
It sounds like you have not installed any Android platforms.


In Eclipse click Window -> Android SDK and AVD Manager
on the left click Available Packages
you should now see the URL to the android repository on google. click the + to expand it
click the checkbox for the android platform you want to target with your app.
click Install Selected on the bottom right
click the radio button for Accept and click install

Once the platform install is complete you should be able to select it as a build target when creating your android project.

You'll also need to create an AVD on which to run/test your project unless you intend to do your testing directly on your phone.

good luck
 
  • Like
Reactions: Christophe2010
Upvote 0
Hey all, thanks for the potential help and time! I fixed it! The reason why I couldn't do all this was because my path variable was missing...well, I had(for some reason..) ;c:\android\tools;...hahaha wtf. This is from that guy who posted about step by step on Eclipse and setting everything up...I guess I just wasn't paying attention. So, after adding C:\...android-sdk-windows\tools; to my path variable. *sigh* lol I feel so stupid. But, thanks to everyone again! I appreciate your assistance and time for something as stupid as my post :( sorry...ciao!
 
Upvote 0
I have been searching for this, and the dang main.xml file!!! :thinking:

This entire thread has helped me find what I was looking for!!

Eclipse is complex and it takes a lot of time to get used to...

Thanks for all these posts, the one that helped me the most was the one that mark posted. I was checking the packages under projects in "Java Browsing" and could not find the res/layout/main.xml!!!

So, I went to Window >> show view >> Project Explorer ... and then found my project and found the res/layout/ folder where I can edit the main.xml file.

Thanks again to everyone who posted on this thread! :)
 
Upvote 0
It is simple
First left click on left panel and u will see no. of folders
there you will find res folder after that there are many folders like layout,values. You have to click on layout and ther you will find main.xml file where you can write your layout code.
And I think so that it is not as much as stupid as you were saying , they give us complete url.
SO if you have any problem now , then you can send me reply..........:)
this stupid website(developer.adroid.com) is so vague! I'm in the resources section trying to do the Hello Views tutorial with the linear layout and it says:

1) Start a new project named HelloLinearLayout
2) Open the res/layout/main.xml file and insert the following: (xml code...)

ok so...I opened up Eclipse. File > New > Project. I named my new project HelloLinearLayout. Ok. Then how the heck do i "open the res/layout/main.xml file"??!?! I click Open and there is no "res/layout/main.xml" file. Please help!
 
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