Eclipse ADT not responding temporarily - android

I am coding on Eclipse-ADT , right now there are too many xlm files and classes in project. When i want to add some code related to the xml members eclipse stop not responding for about 4-5 minutes. I think the problem is on xml search or verification but i am not sure.
For example , to add button , i write Button button1=(Button)findViewById(R.id.button1)
while coding this , there is no problem before (R.id.button1) , but when i write R.id.button1 eclipse crashes.
I searched the related questions on stackoverflow but couldnt manage the find the problem.
P.S : My original project was somewhere else on computer , if i choose the workspace as original locaiton , my project becomes invisible , so i decided to create a new workspace and import my original project. This may cause a problem but any suggestion how to handle it ?

I think it crashes even if it's just not responding. Maybe you don't have any buttons in the current Activity named "button1".
In the XML file, open the code interface and change respective button_id tag to "button1".
In the .java file change the setContentView tro "main" and add the:
(Button) findViewById(R.id.button1);
in your "main".

Related

Android Studio Activity Java File does not recognize XML

I have a big problem. Last I copied a CardView with RecyclerView from a video. After that I created a new empty activity, but the Javafile didn't want to accept the corresponding XML file. And if I go with ALT + ENTER he suggests to me to create your xml file, but afterwards he tells me it already exists. So I can open the XML file, the program recognizes it but it is not recognized in the Java data and I cannot select it there either. There a screen shot, There a picture from solution research, And There a photo of the xml File.
Can someone help me there? Thank you in advance!
I was facing the same problem but you just need to close your project and open it again, the error related to activity file will bee removed!!Just try it.....
maybe you need to rebuild your app
1- Build > clean project
2 - Build > Rebuild project
I hope it will work with you .
Delete those two files. Copy the code first.
Go to File ->new activity then create that activity and paste the code there, besides those lines.

Hello world android - creation with errors

I'm trying to create my first app with Android but I've encountered some problems.
Following a tutorial and making:
new android application -> blank activity
The default result should be:
With MainActivity.java and R.Java inside it.
But instead I've got this:
There are a lot of errors and the R.Java file is missing.
I can obtain a result similar to the tutorial one (with no errors), creating a new android application and unchecking create activity, but this time MainActivity.java under src is totally missing.
Maybe I could copy the MainActivity.java of the first project and put into the second one, but I prefer understand why it doesn't work.
Thanks for the help.
Best regards.
its import library problem
Right click on you application----->Android
under library view ,
check if you have this red error then remove the library and add it again

how to add action buttons in android app

i m having problem in action buttons for my app. i did as per the tutorial from http://developer.android.com/training/basics/actionbar/adding-buttons.html but i get a red underlined error telling there is no file action_search in R.id and no methods openSearch() and openSettings() i fixed this by manually creating the methods and the action_search file and the app run on my device but the search button doesnot works and i now i cannot delete the action_search from R.id plz help
Have you tried running a clean on your build? Whenever you have issues with R. related things try to clean so the resources get rebuilt. This can sometimes be caused by copy and pasting chunks of code around...

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 .
import android.R
android.R are resources from the Android package. TYou need to import your.package.R
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
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.

ImageView Id not being created in R file

Quite new to Android dev so there is a good chance I made a dumb mistake. But for some reason I cant reference a ImageView I created in a second Activity using the findViewById method. When I went and checked the 'R' file I could see that an Id was not created for all 3 ImageViews I am trying to reference that is in the same activity.
What could the possible reason be for this? Could it be something to do with data I put in the Manifest file? My java class? Because my syntax for the containing activity is 100%....
I'm suspecting is has something to do with the new activity/manifest. How can all the ImageViews in the same Activity not be referenced...?
Clean the project and try again. To clean you project Project -> Clean select your project and clean. Some time it happens while developing the project. I've faced many times.

Categories

Resources