• 家庭记账本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秒后关闭

  • 相关阅读:
    实现ls(课上作业)
    20181217 (2)
    20181217 (1)
    ubuntu开启远程ssh登陆本机功能
    解决ubuntu下Could not get lock的问题
    博客园生成目录结构
    np.mean以及np.std用法
    解决 Could not find a version that satisfies the requirement torch==1.4.0
    github下载ocr模型 windows直接解压出问题
    centos7 连接不上网络解决办法
  • 原文地址:https://www.cnblogs.com/znjy/p/14905289.html
Copyright © 2020-2023  润新知