Where is the "content_my.xml" file in Android Studio? - android

In the training docs, it says that the content_my.xml should be in the layout directory. But as you can see in the picture below, it is missing from there. What can I do?

Probably You have selected EmptyActivity instead of BasicActivity during creation of the project.
Go to File -> New -> Activity -> Basic Activity to create it in the same project or just start another project.

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.

How to search and replace all occurrences of a string in Android Studio

I am doing translations on android studio and now I need to replace some strings that I had wrongly translated. When I search using CTRL+SHIFT+F I indeed get all occurrences but when I use the replace shortcut CTRL+SHIFT+R and try to replace I get a quick popup saying Occurrences in project configuration files are skipped then there is a button which says Include them. When I click that button, the find window opens then nothing happens. How do I search and replace from the ENTIRE project including the configuration files?
Select string and use Alt+Shift+R as Eclipse shortcut and Refactor your string, like below screenshots.
There really is no point in editing config files (because all of them are generated by Android Studio) so just don't click the button on the popup you described.
If I am mistaken then tell me what kind of config files you might want to edit.
Edit -> Find -> Replace in path
and then In Project
In Android Studio:
Edit -> Find -> Replace in path

Creating Activity | Android Studio ? [Some concerns]

Till Eclipse, creating a second activity and class had a brevity . However, with the new official Android studio , I feel more of an abstraction . Earlier, while creating an activity it specified many things, nevertheless asked the layout of an XML file. And here are my doubts:
1) Is there an option to create Java file in Android Studio just like we use to do with Eclipse ?
2) Which is the best way to create an activity in Android Studio with our specified layout?
1) You can go into the project directory and right click the folder where you want the activity to be (typically in src/java/com.xxx.xxx/) and select New -> JavaClass and create YourActivity and make sure that YourActivity extends Activity. Be sure to add the activity to your manifest!
2) There is no best way as it is a matter of preference. Personally I do what I said in step 1 and create the xml layout file myself in the res folder. I find that Android Studios auto activity creation to be a bit annoying as they add menu xml files that I do not need.

Eclipse doesn't create acivity_main in /src automatically

I have the newest version of Eclipse (32 bits) and I can't create any activity. Even if i make New -> Other -> Android activity it also doesn't make it. I have Windows 8.
When you create a new Android project by default the activity "MainActivity" and layout "activity_main" are created.
the message activity_main already exists is displayed.
If you want to add another activity with New -> Other -> Android Activity you have to change the name :P.
UPDATE:
https://code.google.com/p/android/issues/detail?id=66647

Eclipse Android setting up a test project

I added a Test project to my main project like it's shown here.
However, when I try to right click and go New -> Class to add a test class, the src folder is set to my main projects source folder, and the package is set to my main projects' package, and the test/ folder doesn't show up when I click on browse.
How do I set the test directory up properly, in Eclipse?
When you click on new class, you get the popup window, where you can set the new package name. (If you're not looking for this, then you should try out new thing below).
You can click on the package(which was created when you made new project), right click that package, then go new and new class to set up properly.
I hope this answer's your question.

Categories

Resources