Es posible, para hacer cosas como estaAndroid, oyente Checkbox en XML?
XML:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<Button android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/addContactButton"
android:text="@string/addContactButtonLabel"
android:onClick="launchContactAdder"/><!-- here -->
</LinearLayout>
Java:
public void launchContactAdder(View v)
{
Intent i = new Intent(this, ContactAdder.class);
startActivity(i);
}
pero no es un requisito, que el método debe ser pública, sin efecto y el más importante toma View como argumento
Ahora me gustaría hacer exactamente lo mismo pero con el botón de casilla de verificación. Casilla de verificación tiene androide: onclick atributo, pero en el tutorial Android (http://developer.android.com/resources/samples/ContactManager/index.html) que puede ver el código
showInvisibleControl.setOnCheckedChangeListener(new OnCheckedChangeListener()
{
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked)
{
Log.d(TAG, "mShowInvisibleControl changed: " + isChecked);
showInvisible = isChecked;
populateContactList();
}
});
así que hay una OnCheckedChanged (CompoundButton buttonView, boolean isChecked) método. ¿Hay alguna forma de hacer esto por XML? No hay ningún atributo android: onCheckedChange, solo el atributo android: onClick, pero como escribí anteriormente, el nombre de ese atributo debe tener el nombre del método correspondiente, que toma View como argumento, pero desde el código anterior entiendo que debo tener un método con CompoundButton y argumentos booleanos.
¿Alguna manera de hacerlo en "forma XML"?