Consider the following layout of an Activity :
<LinearLayout>
<android.support.v7.widget.AppCompatButton
android:id="@+id/btnLogin"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:onClick="clickNoBotao"
android:text="Login"/>
</LinearLayout>
Alterative I:
Button mBotao = (Button) findViewById(R.id.btnCreateAccess);
mBotao.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
//Código aqui
}
});
Alterativa II:
public void clickNoBotao () {
//Código aqui
}
Alterativa III:
public void clickNoBotao (View view) {
//Código aqui
}
Alterativa IV:
Button mBotao = (Button) findViewById(R.id.btnCreateAccess);
mBotao.setOnClick(new View.OnClick() {
@Override
public void onClick(View view) {
//Código aqui
}
});
I'd like to know if these alternatives and the event code conform to the LinearLayout