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.
TextView1andTextView2are not Android classes, howeverTextViewis.So first fix your variable declarations:
Then fix your variable assignment and variable use (note the lowercase):