zoukankan      html  css  js  c++  java
  • 每日日报2021.4.8

    今天完成内容:

    学习andriod checkbox

    <?xml version="1.0" encoding="utf-8"?>
    <TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/tab"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
    <TableRow>
    <TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="喜欢的颜色:"/>
    <LinearLayout
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:orientation="vertical"
    android:layout_gravity="clip_horizontal">
    <CheckBox
    android:id="@+id/box1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="红色"
    android:textColor="@color/chocolate"
    android:checked="true"/>
    <CheckBox
    android:id="@+id/box2"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="蓝色" />
    <CheckBox
    android:id="@+id/box3"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="绿色" />
    </LinearLayout>
    </TableRow>
    <TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:visibility="gone"
    android:id="@+id/show"/>
    </TableLayout>

    <TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/tab"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
    <TableRow>
    <TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="喜欢的颜色:"/>
    <LinearLayout
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:orientation="vertical"
    android:layout_gravity="clip_horizontal">
    <CheckBox
    android:id="@+id/box1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="红色"
    android:textColor="@color/chocolate"
    android:checked="true"/>
    <CheckBox
    android:id="@+id/box2"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="蓝色" />
    <CheckBox
    android:id="@+id/box3"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="绿色" />
    </LinearLayout>
    </TableRow>
    <TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:visibility="gone"
    android:id="@+id/show"/>
    </TableLayout>

    <color name="chocolate">#D2691E</color><!--巧可力色 →
    <color name="black">#000000</color><!--黑色 -->
    <color name="chocolate">#D2691E</color><!--巧可力色 →
    <color name="black">#000000</color><!--黑色 -->

    public class MainActivity extends Activity{
    private TextView show;
    private CheckBox box1,box2,box3;
    private String love= "我喜欢色是";
    private String not= "不是我喜欢的";
    @Override
    protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_layout);
    show = (TextView) findViewById(R.id.show);
    box1 = (CheckBox) findViewById(R.id.box1);
    box2 = (CheckBox) findViewById(R.id.box2);
    box3 = (CheckBox) findViewById(R.id.box3);
    box1.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
    @Override
    public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
    if(isChecked){
    if(show.getVisibility()==View.VISIBLE){
    show.setText(love+box1.getText());
    textColor();
    }else {
    show.setVisibility(View.VISIBLE);
    show.setText(love+box1.getText());
    textColor();
    }
    }else{
    show.setText(not);
    setTextBlack();
    }
    }
    });

    //box2 and box3 和box1的写法一样,在这就不重复写了;


    private void textColor() {
    box3.setTextColor(getApplicationContext().getColor(R.color.chocolate));
    }
    private void setTextBlack() {
    box3.setTextColor(getApplicationContext().getColor(R.color.black));
    }
    }
    }

    看视频

    遇到问题:

    明日目标:

    学习Android studio的开发

  • 相关阅读:
    VisualCaptcha – 灵活的可视化验证码解决方案
    Web Uploader
    Concise
    15个前卫的 HTML5 & CSS3 网页设计作品
    Breach
    字体大宝库:20款超细英文字体免费下载
    使用 JavaScript 实现灵活的固定导航功能
    10套免费的 Photoshop UI 元素以及 PSD 素材
    使用 CSS & jQuery 制作一款漂亮的多彩时钟
    我在美国读博士:才发现美国高等教育如此残酷
  • 原文地址:https://www.cnblogs.com/leiyu1905/p/14912305.html
Copyright © 2011-2022 走看看