本文共 3488 字,大约阅读时间需要 11 分钟。
21春季学期第四、五周
完成Hello World案例app
private void setListeners(){ OnClick toclick = new OnClick(); mButtonLlay.setOnClickListener(toclick);
private class OnClick implements View.OnClickListener{ @Override public void onClick(View v) { Intent intent = null; switch (v.getId()){ case R.id.btn_llay: intent = new Intent(MainActivity.this, LinearLayoutActivity.class); break;
//设置背景,drawable中shape可以设置边框,填充,圆角等,文本的下划线需要在activity中设置//长文本的单行显示效果,android:maxLines="1"是设置为单行,android:ellipsize="end"文本超出时显示省略号 //icon+文字 //阴影效果 //链接,可以从网页直接返回 //跑马灯效果,常用于提示
在activity中监听到“全选”选中后改变同组CheckBox选中状态实现全选效果
@Override public void onCheckedChanged(CompoundButton compoundButton, boolean b) { if(b){ if(compoundButton.getId() == R.id.cb7){ cbx4.setChecked(true); cbx5.setChecked(true); cbx6.setChecked(true); } else Toast.makeText(this,compoundButton.getText().toString(),Toast.LENGTH_SHORT).show(); } else { if(compoundButton.getId() == R.id.cb7){ cbx4.setChecked(false); cbx5.setChecked(false); cbx6.setChecked(false); } } }
xml:
@Override public void onClick(View v) { switch (v.getId()) { case R.id.btn_down: scrollView.fullScroll(ScrollView.FOCUS_DOWN); break; case R.id.btn_up: scrollView.fullScroll(ScrollView.FOCUS_UP); break; } }
转载地址:http://okml.baihongyu.com/