How do I compare if the drawable image "set" in an ImageButton is equal to null for example, or the other Image contained in another Imagebutton?
ImageButton q1 = (ImageButton) findViewById(R.id.q1);
ImageButton q2 = (ImageButton) findViewById(R.id.q2);
ImageButton q3 = (ImageButton) findViewById(R.id.q3);
if (q1.getDrawable() != null &&
q2.getDrawable() != null &&
q3.getDrawable() != null) {
Toast.makeText(this, "Teste 1", Toast.LENGTH_SHORT).show();
if (q1.getDrawable().getConstantState().equals(q2.getDrawable().getConstantState()) &&
q2.getDrawable().getConstantState().equals(q3.getDrawable().getConstantState())) {
Toast.makeText(this, "Teste 2", Toast.LENGTH_SHORT).show();
return true;
}
}
return false;