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的开发

  • 相关阅读:
    ThinkPHP 中入口文件中的APP_DEBUG为TRUE时不报错,改为FALSE时报错
    ASP.NET LinqDataSource数据绑定后,遇到[MissingMethodException: 没有为该对象定义无参数的构造函数。]问题。
    error 2593 operator << 不明确的可能的解决方法
    C++读取mysql中utf8mb4编码表数据乱码问题及UTF8转GBK编码
    arcgis flexviewer中由Application向widget传值
    Flash Builder中“Error: #2036 加载未完成”错误的解决方法
    ArcGIS Server API for JavaScript调用错误:已阻止跨源请求:同源策略禁止读取位于......
    Win10下E3-1231 V3开启Intel虚拟化技术(vt-x)安装HAXM
    GPS accuracy in Android
    解决Win7旗舰版开机后无线网络识别非常慢的问题
  • 原文地址:https://www.cnblogs.com/leiyu1905/p/14912305.html
Copyright © 2011-2022 走看看