首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >这是我用android写的代码studio.It显示找不到符号类TextView.It也显示包R不存在

这是我用android写的代码studio.It显示找不到符号类TextView.It也显示包R不存在
EN

Stack Overflow用户
提问于 2017-02-23 12:21:07
回答 2查看 463关注 0票数 0
代码语言:javascript
复制
package com.example.android.favoritetoys;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;

public class MainActivity extends AppCompatActivity {

    // TODO (1) Declare a TextView variable called mToysListTextView
    TextView mToysListTextView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        mToysListTextView = (TextView).findViewById(R.id.tv_toy_names);
        // TODO (3) Use findViewById to get a reference to the TextView from the layout

        // TODO (4) Use the static ToyBox.getToyNames method and store the names in a String array
        String[] toyNames = ToyBox.getToyNames();
        // TODO (5) Loop through each toy and append the name to the TextView (add \n for spacing)
        for (String toyName : toyNames) {
            mToysListTextView.append(toyName + "\n\n\n");
        }
EN

回答 2

Stack Overflow用户

发布于 2017-06-29 22:32:43

转到您的build.gradle文件。在那里你可以找到下面给出的代码

代码语言:javascript
复制
apply plugin: 'com.android.application'
android {
    compileSdkVersion 25
    buildToolsVersion '25.0.2'

    defaultConfig {
        applicationId "com.android.example.favoritetoys"
        minSdkVersion 10
        targetSdkVersion 25
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:25.1.0'
}

你需要做的就是根据你的“构建工具版本”把它改成buildToolsVersion '25.0.2‘。我正在使用strong textbuildToolsVersion '25.0.1‘

票数 1
EN

Stack Overflow用户

发布于 2017-04-26 05:58:48

您需要导入最后一个类,只需添加

代码语言:javascript
复制
 import android.widget.TextView;
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/42406981

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档