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

  • 相关阅读:
    Oracle查看所有表空间使用情况
    Oracle版本信息查看
    Windows 7关闭和开启系统休眠
    ORACLE 创建表空间
    sp_helpdb使用
    SQL SERVER的数据类型
    博客园开通啦
    http keep alive
    android开发学习
    http与html
  • 原文地址:https://www.cnblogs.com/j-y-s/p/14394512.html
Copyright © 2011-2022 走看看