最佳答案
@Override
public void onClick(View v) {
switch (v.getId())
{
case R.id.legalInformationLL:
startActivity(new Intent(AboutActivity.this, LegalInformation.class));
break;
case R.id.backIB:
finish();
break;
}
}
for this code "Resource IDs will be non-final in Android Gradle Plugin version 5.0, avoid using them in switch case statements" warning shows up. What is the possible solution? If I change this code to:
@Override
public void onClick(View v) {
int id = v.getId();
if (id == R.id.legalInformationLL) {
startActivity(new Intent(AboutActivity.this, LegalInformation.class));
} else if (id == R.id.backIB) {
finish();
}
}
warning goes; but switch statement is better for performance as compared to if statement. So what is the possible solution that will work efficiently faster?