Intellij Idea Android开发R.main

时间:2013-05-08 03:26:41

标签: android intellij-idea

IntelliJ识别R.menu时遇到问题。当我开始新项目时,我编写代码

package com.example.HelloWorld;

import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.widget.TextView;
import android.graphics.Color;


public class MyActivity extends Activity {
    /**
     * Called when the activity is first created.
     */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);


        TextView text = new TextView(this);
        text.setTextColor(Color.RED);
        text.setText("Alex ");
        setContentView(text);


    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }


}

当我在eclipse中执行代码时,它工作正常,但在IntelliJ中它表示cannot resolve symbol 'menu'

任何人都有解决方案吗?

顺便说一句,我是IntelliJ环境的新手

1 个答案:

答案 0 :(得分:0)

基本上,资源中的菜单文件夹缺少xml文件