Marco Livio
Marco Livio

Reputation: 23

TextView1 can't be resolved to a type

I'm trying to finish a tutorial for editable a text declared in the main.xml,

Eclipse says:

-TextView1 can't be resolved to a type

-TextView2 can't be resolved to a type

-TextView1 can't be resolved to a variable

-TextView2 can't be resolved to a variable

-TextView1 can't be resolved

-TextView2 can't be resolved

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.

Upvotes: 1

Views: 1499

Answers (2)

ρяσѕρєя K
ρяσѕρєя K

Reputation: 132982

Change

private TextView1 textView1;
private TextView2 textView2;

to

private TextView  textView1;
private TextView  textView2;

Upvotes: 3

A--C
A--C

Reputation: 36449

TextView1 and TextView2 are not Android classes, however TextView is. 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");

Upvotes: 3

Related Questions