caseb
caseb

Reputation: 37

Android ID not found, when it is there

Android Studio is giving me errors in the Main Activity Java over unresolved symbols or id's. As far as I can see the id's refrenced in the java code exist.

In another app which used these same principles, it worked, I cross refrenced the two apps and could not find anything that stood out.

Here is my java code:

package com.example.android.quizapplication;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import android.widget.SeekBar;
import android.widget.TextView;

public class QuizMainActivity extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_quiz_main);
}
public void display(int value) {
    TextView quantityTextView = findViewById(R.id.value_text);
    quantityTextView.setText(value);
}
public void slider(View view){
    SeekBar seekBar = (SeekBar)findViewById(R.id.i);
    int Value = seekBar.getProgress();
    EditText text = (EditText)findViewById(R.id.valueText);

    String name = text.getText().toString();
    text.setText(Value);
}
}

Here is my XML: (The id's are there)

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout 
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.android.quizapplication.QuizMainActivity">
<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent">
<TextView
    android:id="@+id/title"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:text="Quiz"
    android:textAlignment="center"/>

<TextView
    android:id="@+id/question"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:text="What is you favorite color?"
    android:textAlignment="center"
    android:paddingTop="20dp"
    android:textSize="20dp"
    android:textStyle="bold"

    android:textColor="#000000"
    android:layout_below="@+id/title"
     />
    <TextView
        android:id="@+id/value_text"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="Test"
        android:textAlignment="center"
        android:layout_alignParentBottom="true"
        android:layout_marginBottom="300dp"/>
    <SeekBar
        android:id="@+id/i"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_centerHorizontal="true"
        android:layout_marginBottom="146dp"
        android:onClick="slider"/>


</RelativeLayout>

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Hello World!"
     />

Upvotes: 0

Views: 1623

Answers (1)

Pedro Massango
Pedro Massango

Reputation: 5025

Try adding this:

import com.example.android.quizapplication.R;

Upvotes: 1

Related Questions