1. Buatlah kelas loading.java di package ini.
2. Script loading.java
package thefly.org;
import go_antri.org.PerawatanWajah;
import go_antri.org.R;
import go_antri.org.SelamatDatang;
import go_antri.org.Welcome;
import android.app.Activity;
import android.view.View;
import android.view.View.OnClickListener;
import android.os.Bundle;
import android.content.Intent;
import android.content.pm.ActivityInfo;
public class loading extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.loading);
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
// METHOD 1
/****** Create Thread that will sleep for 5 seconds *************/
Thread background = new Thread() {
public void run() {
try {
// Thread will sleep for 5 seconds
sleep(5*1000);
// After 5 seconds redirect to another intent
Intent i=new Intent(getBaseContext(),SelamatDatang.class);
startActivity(i);
//Remove activity
finish();
} catch (Exception e) {
}
}
};
// start thread
background.start();
//METHOD 2
/*
new Handler().postDelayed(new Runnable() {
// Using handler with postDelayed called runnable run method
@Override
public void run() {
Intent i = new Intent(MainSplashScreen.this, FirstScreen.class);
startActivity(i);
// close this activity
finish();
}
}, 5*1000); // wait for 5 seconds
*/
}
@Override
protected void onDestroy() {
super.onDestroy();
}
}
3. Buat loading.xml di folder layout
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/g"
tools:context=".b'smart" >
<ProgressBar
android:id="@+id/progressBar2"
android:gravity="center|center_horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:indeterminate="false"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
style="?android:attr/progressBarStyleLarge" />
</RelativeLayout>
0 komentar:
Posting Komentar