Boa Tarde pessoal estou lendo a apostila do android 4º edição, e estou com problema na 3º aplicação que se utiliza de checkbox para selecionar produtor e depois exibe o valor total. O código java/android:
package com.example.comprassimples;
import android.os.Bundle;
import android.app.Activity;
import android.app.AlertDialog;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.CheckBox;
public class MainActivity extends Activity {
CheckBox chkarroz, chkfeijao, chkleite, chkcarne;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
chkarroz = (CheckBox) findViewById(R.id.chkarroz);
chkfeijao = (CheckBox) findViewById(R.id.chkfeijao);
chkleite = (CheckBox) findViewById(R.id.chkleite);
chkcarne = (CheckBox) findViewById(R.id.chkcarne);
Button btnlocal = (Button) findViewById(R.id.btncompra);
btnlocal.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View v)
{
double total = 0;
if(chkarroz.isChecked())
total += 2.69;
if(chkfeijao.isChecked())
total += 5.00;
if(chkleite.isChecked())
total += 9.70;
if(chkcarne.isChecked())
total += 2.30;
AlertDialog.Builder dialogo = new
AlertDialog.Builder(MainActivity.this);
dialogo.setTitle("Compras");
dialogo.setMessage("Valor total da compra: "+ String.valueOf(total));
dialogo.setNeutralButton("ok",null);
dialogo.show();
}
});
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.activity_main, menu);
return true;
}
}
o layout é extremamente simples creio que não seja necessario posta-lo aqui.
E o que mais me assustou o erro:
02-24 21:09:55.725: E/AndroidRuntime(884): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.comprassimples/com.example.comprassimples.MainActivity}: android.view.InflateException: Binary XML file line #7: Error inflating class <unknown>