1
resposta

Erro Unfortunately, olamundo has stopped

Testando o exemplo da primeira aula, minha aplicação da o erro "Erro Unfortunately, olamundo has stopped".

protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.principal);

        if (savedInstanceState == null) {
            getSupportFragmentManager().beginTransaction()
                    .add(R.id.container, new PlaceholderFragment()).commit();
        }
        EditText campo = (EditText) findViewById(R.id.campo);

        Button botao = (Button) findViewById(R.id.botao);

        botao.setOnClickListener(new Ouvinte());

    }
public class Ouvinte implements OnClickListener {

    @Override
    public void onClick(View clicada) {
        Log.i("TAG", "botao clicado");

    }

}
1 resposta

Retira esse pedaço de código e roda ai.

if (savedInstanceState == null) {
            getSupportFragmentManager().beginTransaction()
                    .add(R.id.container, new PlaceholderFragment()).commit();
        }