Android加载界面
activity_main.xml
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/activity_main" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingBottom="@dimen/activity_vertical_margin" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" android:orientation="vertical" tools:context="com.toprs.waitingpractice.MainActivity"> <Button android:text="登录" android:layout_width="match_parent" android:layout_height="wrap_content" android:onClick="loginClick" android:id="@+id/button2"/> </LinearLayout>
MainActivity.java
package com.toprs.waitingpractice; import android.content.Intent; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.View; public class MainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); } public void loginClick(View v){ Intent intent = new Intent(); intent.setClass(MainActivity.this,WaitingActivity.class); startActivity(intent); } }
waiting_activity.xml
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/activity_main" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingBottom="@dimen/activity_vertical_margin" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" android:orientation="vertical" tools:context="com.toprs.waitingpractice.MainActivity"> <Button android:text="登录" android:layout_width="match_parent" android:layout_height="wrap_content" android:onClick="loginClick" android:id="@+id/button2"/> </LinearLayout>
WaitingActivity.java
package com.tow.waitingpractice; import android.app.Activity; import android.os.Bundle; import android.os.Handler; import android.widget.Toast; /** * Created by 39867 on 2017/4/18. */ public class WaitingActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.loading_activity); new Handler().postDelayed(new Runnable() { @Override public void run() { WaitingActivity.this.finish(); Toast.makeText(WaitingActivity.this, "登录成功", Toast.LENGTH_SHORT).show(); } },2000); } }
标签:总结,WaitingActivity,05,void,2023,import,android,onCreate From: https://www.cnblogs.com/JJTyyds/p/17375116.html