Java-Android 之单选按钮的运用



    


    
   


    
    

 MainActivity.java

package cn.szy.com;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.TextView;
import android.widget.Toast;

public class MainActivity extends Activity {
    /** Called when the activity is first created. */
	private RadioGroup group;
	private Button button;
	private TextView textView;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        group = (RadioGroup) this.findViewById(R.id.sex);
        button  =(Button) this.findViewById(R.id.select);
        textView = (TextView) this.findViewById(R.id.text);
        button.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                // Perform action on click
            	int len = group.getChildCount();
            	String msg = "您选择了";
            	textView.setText(msg);
            	
//            	for(int i=0;i

 

你可能感兴趣的:(Java-Android 之单选按钮的运用)