Professional Documents
Culture Documents
/***************AndroidManifest.xml***************/
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="sample2.thread"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk android:minSdkVersion="8" />
</application>
</manifest>
/***************main.xml***************/
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/bluehills"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello"
/>
</LinearLayout>
/***************main1.xml***************/
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/sunset"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello"
/>
</LinearLayout>
/***************main2.xml***************/
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/winter"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello"
/>
</LinearLayout>
/*************** Sample2threadActivity.java***************/
package sample2.thread;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
@Override
public void run() {
// TODO Auto-generated method stub
try {
Thread.sleep(1000);
Intent in =new
Intent(Sample2threadActivity.this,sec.class);
startActivity(in);
} catch (Exception e) {
// TODO: handle exception
}
}
}).start();
}
}
/*************** sec.java***************/
package sample2.thread;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
@Override
public void run() {
// TODO Auto-generated method stub
try {
Thread.sleep(1000);
Intent in =new Intent(sec.this,third.class);
startActivity(in);
} catch (Exception e) {
// TODO: handle exception
}
}
}).start();
}
}
/*************** third.java***************/
package sample2.thread;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
@Override
public void run() {
// TODO Auto-generated method stub
try {
Thread.sleep(5000);
/*Intent in =new Intent(third.this,third.class);
startActivity(in);*/
} catch (Exception e) {
// TODO: handle exception
}
}
}).start();
}
}
OUTPUT