Ejercicio en Android Studio
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.RadioButton;
import android.widget.Toast;
public class MainActivity extends AppCompatActivity {
private RadioButton S1,S2,S3;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
S1= (RadioButton) findViewById(R.id.radioButton);
S2= (RadioButton) findViewById(R.id.radioButton2);
S3= (RadioButton) findViewById(R.id.radioButton3);
}
public void seleccion(View view){
if(S1.isChecked()==true){
Toast.makeText(this,"seleccion 1",Toast.LENGTH_LONG).show();
}else if(S2.isChecked()==true){
Toast.makeText(this,"seleccion 2",Toast.LENGTH_LONG).show();
}else if(S3.isChecked()==true){
Toast.makeText(this,"seleccion 3",Toast.LENGTH_LONG).show();
}
}
}


No hay comentarios:
Publicar un comentario