import
android.widget.*;
import
android.view.*;
import
android.view.View.OnClickListener;
public
class MainActivity extends Activity {
RadioButton r1,r2;
RadioGroup rg;
Button b1;
@Override
protected
void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
r1=(RadioButton)
findViewById(R.id.radio0);
r2=(RadioButton)
findViewById(R.id.radio1);
rg=(RadioGroup)
findViewById(R.id.radioGroup1);
b1=(Button) findViewById(R.id.button1);
b1.setOnClickListener(L1);
}
public OnClickListener L1=new
OnClickListener()
{
public void onClick(View v)
{
if(v==b1)
{
if(r1.isChecked()==true)
Toast.makeText(getBaseContext(),r1.getText(),Toast.LENGTH_LONG).show();
if(r2.isChecked()==true)
Toast.makeText(getBaseContext(),r2.getText(),Toast.LENGTH_LONG).show();
}
}
};
}
No comments:
Post a Comment