Wednesday, July 07, 2010

Google Android Development "Hello, Views" and Tips for API 7

final CheckBox checkbox = (CheckBox) findViewById(R.id.checkbox);
checkbox.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
// Perform action on clicks, depending on whether it's now
// checked
if (((CheckBox) v).isChecked()) {
Toast.makeText(HelloFormStuff.this, "Selected",
Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(getApplicationContext(), "Not selected",
Toast.LENGTH_SHORT).show();
}
}
});


The text in Green Worked for me, the text in Red did not work for me.

No comments: