Sarah
Sarah

Reputation: 1

Editing layout in Android

I have two questions :

I am developing part of an Android App , in the main activity I added two text fields and one button and I am trying to call them by id as shown below :

Send = (Button)findViewById(R.id.Send)   // Giving error in Send 
StudentName=(EditText)findViewById(R.id.edittext);   // Giving error in edittext 

and then I added OnClickListener to the button , as shown below :

Send.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                job = new MyJob();
                job.execute();
            }
        });

I added both Send (my button and the textfields) in the R.java but it is not accepting them because the modification was done manually . I added import android.R , but it did not solve the problem .

My second question :

I am trying to edit my layout (graphically) but I do not know how to show it in eclipse !!!

Please Help me and sorry if my questions are stupid .

Upvotes: 0

Views: 54

Answers (3)

Adnan Zahid
Adnan Zahid

Reputation: 583

Firstly, delete the "Gen" (automatically generated files) package and then clean the project, the errors will go away.

Secondly, for layout design you can open the .xml files and switch to design tab for the GUI way to edit layouts. Hope that makes sense.

Upvotes: 0

Matthew Pigram
Matthew Pigram

Reputation: 1430

For editing a layout in Eclipse open up the XML for the view/layout you are making. Then at the bottom of the code just above the tabs that say declaration, problems, javadoc there should be a tab that says Graphical Layout this will show your layout graphically.

Importing stuff by Id is done how blackbelt has said

Upvotes: 0

Blackbelt
Blackbelt

Reputation: 157437

import android.R

android.R are resources from the Android package. TYou need to import your.package.R

Upvotes: 3

Related Questions