简体   繁体   English

TextView1无法解析为一种类型

[英]TextView1 can't be resolved to a type

I'm trying to finish a tutorial for editable a text declared in the main.xml, 我正在尝试完成一个教程,以使main.xml中声明的文本可编辑,

Eclipse says: Eclipse说:

-TextView1 can't be resolved to a type -TextView1无法解析为类型

-TextView2 can't be resolved to a type -TextView2无法解析为一种类型

-TextView1 can't be resolved to a variable -TextView1无法解析为变量

-TextView2 can't be resolved to a variable -TextView2无法解析为变量

-TextView1 can't be resolved -TextView1无法解析

-TextView2 can't be resolved -TextView2无法解析

here is my code: 这是我的代码:

package marco.prova;

import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;

public class Main extends Activity {
    private TextView1 textView1;
    private TextView2 textView2;

    /** Called when the activity is first created.*/

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

        TextView1 = (TextView) findViewById(R.id.testo1);
        TextView1.setText("Testo modificato tramite codice 1");

        TextView2 = (TextView) findViewById(R.id.testo2);
        TextView2.setText("Testo modificato tramite codice 2");
    }
}

Thanks for the help. 谢谢您的帮助。

TextView1 and TextView2 are not Android classes, however TextView is. TextView1TextView2不是Android类,但是TextView是。 So first fix your variable declarations: 因此,首先修复您的变量声明:

private TextView textView1;
private TextView textView2;

Then fix your variable assignment and variable use (note the lowercase): 然后修复变量分配和变量使用(注意小写):

textView1 = (TextView) findViewById(R.id.testo1);
textView1.setText("Testo modificato tramite codice 1");

textView2 = (TextView) findViewById(R.id.testo2);
textView2.setText("Testo modificato tramite codice 2");

Change 更改

private TextView1 textView1;
private TextView2 textView2;

to

private TextView  textView1;
private TextView  textView2;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM