@pritchin_maxim1
Начинающий IT-Разработчик

Почему возникает ошибка компиляции Android приложения?

Как я предполагаю нужно использовать this но не могу понять как это сделать

package com.rgapp;

import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

public class ServerCard extends RelativeLayout {
    TextView textViewTitle;
    TextView textViewValue;
    ImageView imageView;

    String Name;

    public ServerCard(Context context) {
        super(context);
        init(context);
    }

    public ServerCard(Context context, AttributeSet attrs) {
        super(context, attrs);
        init(context);
    }

    public ServerCard(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
        init(context);
    }

    private void init(Context context) {
        View.inflate(context, R.layout.servercard, this);
        setDescendantFocusability(FOCUS_BLOCK_DESCENDANTS);
        textViewTitle = (TextView) findViewById(R.id.textViewTitle);
        textViewValue = (TextView) findViewById(R.id.textViewValue);
        imageView = (ImageView) findViewById(R.id.imageView);

    }

    public void setTitleText(String text) {
        textViewTitle.setText(text);
    }

    public void setValueText(String text) {
        textViewValue.setText(text);
    }
}


Ошибка
error: cannot find symbol
        textViewTitle = (TextView) findViewById(R.id.textViewTitle);
                                                                               ^
  symbol:   variable textViewTitle
  location: class id
  • Вопрос задан
  • 104 просмотра
Решения вопроса 1
azerphoenix
@azerphoenix Куратор тега Java
Java Software Engineer
Реимпортируйте класс R..
Затем почистите кеш (Invalidate cache & restart) и перезапустите заново. Должно помочь.
Также проверьте есть ли в xml такой id R.id.textViewTitle
Ответ написан
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы