zoukankan      html  css  js  c++  java
  • 2021年1月16日 秒表app

    今天学习了秒表app的制作:

     

    MainActivity:

    <?xml version="1.0" encoding="utf-8"?>
    <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        xmlns:tools="http://schemas.android.com/tools"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        tools:context=".MainActivity">
    
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical">
    
            <TextView
                android:id="@+id/timeview"
                android:layout_width="match_parent"
                android:layout_height="47dp"
                android:gravity="center_horizontal"
                android:text="0:00:00"
                android:textAppearance="@style/TextAppearance.AppCompat.Large" />
    
            <Button
                android:id="@+id/button_start"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center_horizontal"
                android:onClick="onClickStart"
                android:text="@string/start" />
    
            <Button
                android:id="@+id/button_stop"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center_horizontal"
                android:onClick="onClickStop"
                android:text="@string/stop" />
    
            <Button
                android:id="@+id/button_reset"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center_horizontal"
                android:onClick="onClickReset"
                android:text="@string/reset" />
        </LinearLayout>
    </androidx.constraintlayout.widget.ConstraintLayout>

    activity_main.xml:

    <?xml version="1.0" encoding="utf-8"?>
    <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        xmlns:tools="http://schemas.android.com/tools"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        tools:context=".MainActivity">
    
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical">
    
            <TextView
                android:id="@+id/timeview"
                android:layout_width="match_parent"
                android:layout_height="47dp"
                android:gravity="center_horizontal"
                android:text="0:00:00"
                android:textAppearance="@style/TextAppearance.AppCompat.Large" />
    
            <Button
                android:id="@+id/button_start"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center_horizontal"
                android:onClick="onClickStart"
                android:text="@string/start" />
    
            <Button
                android:id="@+id/button_stop"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center_horizontal"
                android:onClick="onClickStop"
                android:text="@string/stop" />
    
            <Button
                android:id="@+id/button_reset"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center_horizontal"
                android:onClick="onClickReset"
                android:text="@string/reset" />
        </LinearLayout>
    </androidx.constraintlayout.widget.ConstraintLayout>

    strings.xml:

    <resources>
        <string name="app_name">Stopwatch</string>
        <string name="start">Start</string>
        <string name="stop">Stop</string>
        <string name="reset">Reset</string>
    </resources>

    遇到的问题:

    有一个小bug:旋转屏幕改变了设备配置device configuration
    设备配置包括:系统语言、屏幕大小、屏幕方向、是否外接键盘改设备配置会导致Activity被销毁后新建

  • 相关阅读:
    Redis详解(三)- redis的六大数据类型详细用法
    Redis详解(二)- redis的配置文件介绍
    《OR Talk NO.11 | 清能互联赖晓文:电力系统中的运筹优化应用》
    《OR Talk NO.10 | 浙江大学徐金明:分布式优化算法何时能在性能上与集中式算法相媲美?》
    《OR Talk NO.9 | 深圳大学龚元浩:比几何流快一万倍的曲率滤波算法》
    《OR Talk NO.4 | Attain.ai 创始人李玉喜:强化学习遇见组合优化》
    《OR Talk NO.3 | 滴滴 AI Labs 秦志伟:深度强化学习在网约che交易市场中的应用》
    《OR Talk NO.2 | 胡武华博士:运筹优化理论在物流行业中的应用实践》
    《KDD 2018 | Conventional Tutorials》
    《OR Talk NO.13 | MIT 博士与你分享电商供应链算法实战心得》
  • 原文地址:https://www.cnblogs.com/j-y-s/p/14394512.html
Copyright © 2011-2022 走看看