• Android课程设计第六天欢迎界面(跳转)


    注意:课程设计只为完成任务,不做细节描述~ 

    package com.example.myapplication;
    
    import android.app.Activity;
    import android.content.Intent;
    import android.os.Bundle;
    import android.os.Handler;
    import android.view.View;
    import android.widget.TextView;
    
    /**
     * Created by 樱花落舞 on 2017/6/13.
     */
    
    public class JumpActivity extends Activity {
        TextView textView;
        int time=3;
        Handler handler=new Handler();
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.jump);
            textView= (TextView) findViewById(R.id.textview);
    
            handler.postDelayed(runnable,1000);
    
        }
    
        Runnable runnable=new Runnable() {
            @Override
            public void run() {
                time--;
                handler.postDelayed(this,1000);
                textView.setText("+"+time+"s");
    
                if(time==0){
                    Intent intent = new Intent(JumpActivity.this,TestActivity.class);
                    startActivity(intent);
                    finish();
                }else {
                    textView.setOnClickListener(new View.OnClickListener() {
                        @Override
                        public void onClick(View v) {
                            Intent intent=new Intent(JumpActivity.this,TestActivity.class);
                            startActivity(intent);
                            //结束线程
                            handler.removeCallbacks(runnable);
                            finish();
                        }
                    });
                }
            }
        };
    }
    package com.example.myapplication;
    
    import android.content.Intent;
    import android.support.v7.app.AppCompatActivity;
    import android.os.Bundle;
    
    public class MainActivity extends AppCompatActivity {
    
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
            intent.setClass(MainActivity.this,JumpActivity.class);
            startActivity(intent);
            MainActivity.this.finish();
        }
        Intent intent = new Intent();
    }
    package com.example.myapplication;
    
    import android.app.Activity;
    import android.os.Bundle;
    import android.support.annotation.Nullable;
    
    /**
     * Created by 樱花落舞 on 2017/6/13.
     */
    
    public class TestActivity extends Activity {
        @Override
        protected void onCreate(@Nullable Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.empty_activity);
        }
    }
    <?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout 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="com.example.myapplication.MainActivity"
    
        android:orientation="vertical">
        <ImageView
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:src="@mipmap/bg"/>
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="+3秒"
            android:id="@+id/text"
            android:textSize="20dp"
            android:layout_alignParentRight="true"/>
    
    
    </RelativeLayout>
    <?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent" android:layout_height="match_parent">
       <TextView
           android:layout_width="wrap_content"
           android:layout_height="wrap_content"
           android:background="@mipmap/a"/>
    </RelativeLayout>
    <?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent" android:layout_height="match_parent"
        android:orientation="vertical">
        <ImageView
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:src="@mipmap/bg"/>
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:id="@+id/textview"
            android:textSize="20sp"
            android:text="+3s"
            android:layout_alignParentRight="true"/>
    </RelativeLayout>
    <?xml version="1.0" encoding="utf-8"?>
    <manifest xmlns:android="http://schemas.android.com/apk/res/android"
        package="com.example.myapplication">
    
        <application
            android:allowBackup="true"
            android:icon="@mipmap/ic_launcher"
            android:label="@string/app_name"
            android:roundIcon="@mipmap/ic_launcher_round"
            android:supportsRtl="true"
            android:theme="@style/AppTheme">
            <activity android:name=".MainActivity">
                <intent-filter>
                    <action android:name="android.intent.action.MAIN" />
    
                    <category android:name="android.intent.category.LAUNCHER" />
                </intent-filter>
            </activity>
            <activity android:name=".JumpActivity"
                android:label="@string/app_name"
            >
                <meta-data
                    android:name="android.support.PARENT_ACTIVITY"
                    android:value=".MainActivity"/>
            </activity>
            <activity android:name=".TestActivity"
                android:label="@string/app_name">
                <meta-data
                    android:name="android.support.PARENT_ACTIVITY"
                    android:value=".MainActivity"/>
    
    
            </activity>
        </application>
    
    </manifest>
  • 相关阅读:
    mongodb studio 3t 破解无限使用脚本
    香港低价linux虚拟主机,
    c#4.0 Task.Factory.StartNew 用法
    系统进不去怎么办?教你利用bootice工具引导修复系统
    用一个URL加一个JAVA壳做成一个安卓应用
    ANDROID开机动画分析
    你的Android不好用,都是因为这几点原因
    横竖屏切换时不销毁当前activity 和 锁定屏幕
    APP流氓大法之apk 静默安装
    设备管理器勾选后不能再取消了
  • 原文地址:https://www.cnblogs.com/yinghualuowu/p/7100714.html
Copyright © 2020-2023  润新知