In this code the mentioned error occurs, pointing to the CarregarTelaPrincipal()
method. Why is it occurring?
package com.example.usuario.myapp;
import android.app.Activity;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ImageButton;
public class MyActivity extends Activity {
ImageButton button1;
Button btvoltar;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_my);
CarregarTelaPrincipal();
}
public void CarregarTelaPrincipal(){
button1 = (ImageButton) findViewById(R.id.button1);
button1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
CarregarTela1();
}
});
}
public void CarregarTela1(){
setContentView(R.layout.tela_1);
btvoltar = (Button) findViewById(R.id.btvoltar);
btvoltar.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
CarregarTelaPrincipal();
}
});
}
}