无法解析标记R [英] Cannot Resolve symbol R

查看:1165
本文介绍了无法解析标记R的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是工作在Android Studio中添加一个短敬酒消息。(我是作出Android Wear应用程序)

我不知道为什么会这样code对'符号R'的错误。
它说:不能解析符号R。

请帮我..:(

 进口android.app.Activity;
    进口android.content.Context;
    进口android.content.DialogInterface;
    进口android.os.Bundle;
    进口android.support.wearable.view.WatchViewStub;
    进口android.view.View;
    进口android.widget.Button;
    进口android.widget.TextView;
    进口android.widget.Toast;    公共类MyActivity延伸活动{        私人TextView的mTextView;        @覆盖
        保护无效的onCreate(捆绑savedInstanceState){
            super.onCreate(savedInstanceState);
            的setContentView(R.layout.activity_my);    // getnextpage
    按钮getnextpage;
    getnextpage =(按钮)findViewById(R.id.getnextpage);
    getnextpage.setOnClickListener(新OnclickListener(){
        公共无效的onClick(视图v){
            Toast.makeText(getApplicationContext(),这是第2页,Toast.LENGTH_LONG).show();
        }
    });
    最后WatchViewStub存根=(WatchViewStub)findViewById(R.id.watch_view_stub);
    stub.setOnLayoutInflatedListener(新WatchViewStub.OnLayoutInflatedListener(){
        @覆盖
        公共无效onLayoutInflated(WatchViewStub存根){
            mTextView =(TextView中)stub.findViewById(R.id.text);
        }
    });
  }
 }


解决方案

以下几种方式:

1)建立 - >重建项目

2)进口.R。

3)完成其相应的XML文件中的所有资源。

我希望他们中的任何一个是û有帮助的。

I was working on Android Studio for adding a short toast message.(I was making an Android Wear Application)

I couldn't know why this code has error on 'symbol R' . It says "Cannot Resolve Symbol R."

Please help me.. :(

    import android.app.Activity;
    import android.content.Context;
    import android.content.DialogInterface;
    import android.os.Bundle;
    import android.support.wearable.view.WatchViewStub;
    import android.view.View;
    import android.widget.Button;
    import android.widget.TextView;
    import android.widget.Toast;

    public class MyActivity extends Activity {

        private TextView mTextView;

        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_my);

    //getnextpage
    Button getnextpage;
    getnextpage = (Button) findViewById(R.id.getnextpage);
    getnextpage.setOnClickListener(new OnclickListener() {
        public void onClick(View v) {
            Toast.makeText(getApplicationContext(), "Here is 2nd Page", Toast.LENGTH_LONG).show();
        }
    });
    final WatchViewStub stub = (WatchViewStub) findViewById(R.id.watch_view_stub);
    stub.setOnLayoutInflatedListener(new WatchViewStub.OnLayoutInflatedListener() {
        @Override
        public void onLayoutInflated(WatchViewStub stub) {
            mTextView = (TextView) stub.findViewById(R.id.text);
        }
    });
  }
 }

解决方案

following ways :

1) Build -> Rebuild project .

2) import .R .

3) complete all resources of its corresponding XML file .

I hope any one of them is helpful for u.

这篇关于无法解析标记R的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆