• 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被销毁后新建

  • 相关阅读:
    ProxySQL查看所有的全局变量及更新操作
    MySQL8.0报错:Access denied; you need (at least one of) the SYSTEM_USER privilege(s) for this operation
    ProxySQL 使用情况报错问题汇总及解决办法
    ProxySQL(7):详述ProxySQL的路由规则
    ProxySQL(1):简介和安装
    ProxySQL配置之MySQL服务器配置
    ProxySQL(6):管理后端节点
    小心使用replicate_do_db和replicate_ignore_db
    ProxySQL Cluster 概述
    ProxySQL(3):Admin管理接口
  • 原文地址:https://www.cnblogs.com/j-y-s/p/14394512.html
Copyright © 2020-2023  润新知