android:layout_width=“match_parent”
android:layout_height=“wrap_content”
android:text=“RadioButton2” />
<RadioButton
android:id=“@+id/radioButton3”
android:layout_width=“match_parent”
android:layout_height=“wrap_content”
android:text=“RadioButton3” />
<CheckBox
android:id=“@+id/checkBox1”
android:layout_width=“match_parent”
android:layout_height=“wrap_content”
android:text=“CheckBox1” />
<CheckBox
android:id=“@+id/checkBox2”
android:layout_width=“match_parent”
android:layout_height=“wrap_content”
android:text=“CheckBox2” />
<CheckBox
android:id=“@+id/checkBox3”
android:layout_width=“match_parent”
android:layout_height=“wrap_content”
android:text=“CheckBox3” />
3.修改MainActivity。
public class MainActivity extends AppCompatActivity implements AdapterView.OnItemSelectedListener, View.OnClickListener, CompoundButton.OnCheckedChangeListener {
private Spinner spinner;
private Button button1;
private Button button2;
private RadioButton radioButton1;
private RadioButton radioButton2;
private RadioButton radioButton3;
private CheckBox checkBox1;
private CheckBox checkBox2;
private CheckBox checkBox3;
private String[] list= new String[]{“下拉选项1”,“下拉选项2”,“下拉选项3”,“下拉选项4”};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
spinner = findViewById(R.id.spinner);
button1 = findViewById(R.id.button1);
button2 = findViewById(R.id.button2);
radioButton1 = findViewById(R.id.radioButton1);
radioButton2 = findViewById(R.id.radioButton2);
radioButton3 = findViewById(R.id.radioButton3);
checkBox1 = findViewById(R.id.checkBox1);
checkBox2 = findViewById(R.id.checkBox2);
checkBox3 = findViewById(R.id.checkBox3);
spinner.setOnItemSelectedListener(this);
button1.setOnClickListener(this);
button2.setOnClickListener(this);
radioButton1.setOnClickListener(this);
radioButton2.setOnClickListener(this);
radioButton3.setOnClickListener(this);
checkBox1.setOnCheckedChangeListener(this);
checkBox2.setOnCheckedChangeListener(this);
checkBox3.setOnCheckedChangeListener(this);
spinner.setAdapter(new ArrayAdapter(this,android.R.layout.simple_spinner_item,list));
}
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
Toast.makeText(this, “当前选中的是”+list[position], Toast.LENGTH_SHORT).show();
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
}
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.button1:
new DatePickerDialog(MainActivity.this, new DatePickerDialog.OnDateSetListener() {
@Override
自我介绍一下,小编13年上海交大毕业,曾经在小公司待过,也去过华为、OPPO等大厂,18年进入阿里一直到现在。
深知大多数初中级安卓工程师,想要提升技能,往往是自己摸索成长,但自己不成体系的自学效果低效又漫长,而且极易碰到天花板技术停滞不前!
因此收集整理了一份《2024年最新Android移动开发全套学习资料》送给大家,初衷也很简单,就是希望能够帮助到想自学提升又不知道该从何学起的朋友,同时减轻大家的负担。
由于文件比较大,这里只是将部分目录截图出来,每个节点里面都包含大厂面经、学习笔记、源码讲义、实战项目、讲解视频
如果你觉得这些内容对你有帮助,可以添加下面V无偿领取!(备注Android)
66063)]
[外链图片转存中…(img-lukJYnoh-1710930366063)]
由于文件比较大,这里只是将部分目录截图出来,每个节点里面都包含大厂面经、学习笔记、源码讲义、实战项目、讲解视频
如果你觉得这些内容对你有帮助,可以添加下面V无偿领取!(备注Android)
[外链图片转存中…(img-lo2XbtjO-1710930366064)]