InsaneCoder
InsaneCoder

Reputation: 8268

My activity is unable to resolve a symbol to the layout file

I have the following activity

package com.example.responsivelayout;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.TextView;

public class DisplayText extends AppCompatActivity {

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

        Intent intent = getIntent();
        String message = intent.getStringExtra("com.example.responsivelayout.MESSAGE");

        TextView tv = (TextView)findViewById(R.id.user_text);
        tv.setText(message);
    }
}

But the line setContentView(R.layout.activity_displaytext); gives error as "cannot resolve symbol". I have the following layout file as activity_displaytext.xml:

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
    xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent"
    android:layout_height="match_parent">

</android.support.constraint.ConstraintLayout>

which is present in the layout/ folder. After trying all the efforts, i am clueless why i am getting this error. I tried project clean, make, eveything. Please help.

enter image description here

Upvotes: 0

Views: 209

Answers (1)

Hardik Bambhania
Hardik Bambhania

Reputation: 1792

Make sure below import is not there

import android.R; //Resource class

It may be issue with import

Import should be

import com.example.responsivelayout.R;

Upvotes: 1

Related Questions