import android.os.Bundle; import android.view.Menu; import android.view.View; import android.widget.CheckBox; import android.widget.RadioButton; import android.widget.TextView;
public class CheckActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main);
final TextView tv=(TextView)this.findViewById(R.id.text01);
final CheckBox checkbox1=(CheckBox)this.findViewById(R.id.checkBox1); final CheckBox checkbox2=(CheckBox)this.findViewById(R.id.checkBox2);
final RadioButton
radiobutton1=(RadioButton )this.findViewById(R.id.radioButton1); final RadioButton
radiobutton2=(RadioButton )this.findViewById(R.id.radioButton2);
/* CheckBox.OnClickListener checkboxListener=new CheckBox.OnClickListener() {
checkbox1.setOnClickListener(checkboxListener); checkbox2.setOnClickListener(checkboxListener);*/
public void onClick(View v) { } });
// TODO Auto-generated method stub tv.setText(\被选中\ };
public void onClick(View v) { }
// TODO Auto-generated method stub
tv.setText(\
checkbox1.setOnClickListener(new View.OnClickListener() {
checkbox2.setOnClickListener(new View.OnClickListener() {
}
@Override
public void onClick(View v) { } }); /* };
radiobutton1.setOnClickListener(radioButtonListener); radiobutton2.setOnClickListener(radioButtonListener);*/
public void onClick(View v) { } });
public void onClick(View v) { } }) ;
// TODO Auto-generated method stub tv.setText(\被选中\// TODO Auto-generated method stub tv.setText(\被选中\
RadioButton.OnClickListener radioButtonListener = new
public void onClick(View v) { }
// TODO Auto-generated method stub radiobutton1.setText(\radiobutton2.setText(\// TODO Auto-generated method stub tv.setText(\被选中\
RadioButton.OnClickListener() {
radiobutton1.setOnClickListener(new View.OnClickListener() {
radiobutton2.setOnClickListener(new View.OnClickListener() {
public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.main, menu); return true; }
}
Main.xml中的代码 xmlns:android=\ xmlns:tools=\ android:layout_width=\ android:layout_height=\ > android:id=\ android:layout_width=\ android:layout_height=\ android:layout_centerHorizontal=\ android:layout_centerVertical=\ android:text=\ tools:context=\ /> android:id=\ android:layout_width=\ android:layout_height=\ android:layout_alignParentLeft=\ android:layout_alignParentTop=\ android:text=\ /> android:id=\ android:layout_width=\ android:layout_height=\ android:layout_alignParentLeft=\ android:layout_below=\ android:text=\ /> android:id=\ android:layout_width=\ android:layout_height=\ android:layout_alignParentLeft=\ android:layout_below=\ android:text=\ /> android:id=\ android:layout_width=\ android:layout_height=\ android:layout_alignParentLeft=\ android:layout_below=\ android:text=\ />
5.2.4spiner 代码 Main.xml代码
xmlns:android=\ android:layout_width=\ android:layout_height=\ > android:id=\ android:layout_width=\ android:layout_height=\ android:layout_weight=\ />
Main代码
package lynu.cyp;
import java.util.ArrayList; import java.util.List;
import android.app.Activity; import android.os.Bundle; import android.view.Menu;
import android.widget.ArrayAdapter; import android.widget.Spinner; import android.widget.TextView;
public class SpinnerActivity extends Activity {
相关推荐: