Reputation: 930
Okay, I'm completely lost on this one. I see that there are other posts on this topic, but they don't seem to address the odd behavior I'm experiencing.
I'm working in Android Studio 1.0.1 I started a new project from a template using a blank activity. Created a Menu File that contains the following:
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:yourapp="http://schemas.android.com/apk/res-auto">
<item android:id="@+id/edit_holidays"
android:icon="@drawable/ic_launcher"
android:title="@string/action_edit_holidays"
yourapp:showasaction="ifRoom" />
</menu>
I then went to run the application and it gave me a no resource identifier found for attribute 'showasaction'... message
But worse, I noticed that my MainActivity.java file suddenly had red squigglies under it, and upon checking it, all of the 'R' references went red with a 'cannot resolve R'
Based on other posts, I added import.android.R, which had not been there, though it seemed to resolve the R's. Then, however, the calls to my xml files turned red and could not be resolved, such as in
setContentView(R.layout.activity_main);
Any ideas what might have happened and how to fix it?
Upvotes: 1
Views: 144
Reputation: 2696
If after rebuilding you, suddenly, get lot's of errors. Then you should recheck the XML files. If they are not parsed correctly, for whatever reason (possibly even empty lines), the project will turn red (so to speak)
Upvotes: 0
Reputation: 20128
Adding the android.R
import is not the way to go. Have you tried rebuilding the project (Build -> Rebuild)? This should regenerate the R file. I also think capitalization might be important - try showAsAction
rather than showasaction
in the menu xml file.
Upvotes: 1