zoukankan      html  css  js  c++  java
  • 家庭记账本day2

    完成记账本的启动界面

    LauncherActivity文件:

     1 package com.example.application_keep;
     2 
     3 import androidx.appcompat.app.AppCompatActivity;
     4 
     5 import android.app.Activity;
     6 import android.content.Intent;
     7 import android.os.Bundle;
     8 import android.os.Handler;
     9 
    10 public class LauncherActivity extends Activity {
    11 
    12     @Override
    13     protected void onCreate(Bundle savedInstanceState) {
    14         super.onCreate(savedInstanceState);
    15         setContentView(R.layout.activity_launcher);
    16         new Handler().postDelayed(new Runnable() {
    17             @Override
    18             public void run() {
    19                 //在主线程中执行
    20                 startMainActivity();
    21             }
    22         },2000);
    23     }
    24     //启动主页面
    25     private void startMainActivity(){
    26         Intent intent=new Intent(this,MainActivity.class);
    27         startActivity(intent);
    28         //关闭当前页面
    29         finish();
    30     }
    31 }

    activity_launcher.xml文件:

     1 <?xml version="1.0" encoding="utf-8"?>
     2 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
     3     xmlns:app="http://schemas.android.com/apk/res-auto"
     4     xmlns:tools="http://schemas.android.com/tools"
     5     android:layout_width="match_parent"
     6     android:layout_height="match_parent"
     7     android:background="@android:color/white"
     8     tools:context=".LauncherActivity">
     9 
    10     <ImageView
    11         android:id="@+id/la_icon"
    12         android:layout_width="wrap_content"
    13         android:layout_height="wrap_content"
    14         android:src="@drawable/ks"
    15 
    16         android:layout_centerInParent="true"
    17         />
    18 
    19     <TextView
    20         android:layout_width="wrap_content"
    21         android:layout_height="wrap_content"
    22         android:layout_below="@id/la_icon"
    23         android:layout_marginTop="-48dp"
    24         android:text="家庭记账本"
    25         android:layout_centerHorizontal="true"
    26         android:textColor="@android:color/black"
    27         android:textSize="35sp" />
    28 </RelativeLayout>

    需要注意的是,要在AndroidManifest文件中将LauncherActivity设置为启动界面

     效果:

    启动APP时,出现启动界面,3秒后关闭

  • 相关阅读:
    P2015 二叉苹果树(树形DP)
    Treats for the Cows (区间DP)
    You Are the One(区间DP 好题)
    Palindrome subsequence (区间DP)
    Cutting Sticks(区间DP)
    L2-013 红色警报 (dfs判断图连通性)
    L2-001 紧急救援 (dijkstra+dfs回溯路径)
    多线程 -- JMM、volatile关键字、内存屏障、happens-before原则、缓存一致性
    多线程 -- 各种锁的概念
    Spring Boot 学习笔记(十六)启动原理、运行流程、自动配置原理
  • 原文地址:https://www.cnblogs.com/znjy/p/14905289.html
Copyright © 2011-2022 走看看