splash screen example in android
ScreenShots:
</manifest>
ScreenShots:
String.xml
<?xmlversion="1.0"encoding="utf-8"?>
<resources>
<stringname="app_name">SplashScreen</string>
<stringname="action_settings">Settings</string>
<stringname="hello_world">Welcome</string>
<stringname="name">Welcome to Second Screen</string>
<stringname="title_activity_second">SecondActivity</string>
</resources>
Activity_main.xml
<RelativeLayoutxmlns: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:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity">
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/hello_world"/>
<ImageView
android:id="@+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/textView1"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_below="@+id/textView1"
android:src="@drawable/lolipopn"/>
</RelativeLayout>
MainActivity.java
importandroid.app.Activity;
importandroid.os.Bundle;
importandroid.view.View;
importandroid.view.View.OnClickListener;
importandroid.widget.Button;
importandroid.widget.ImageView;
publicclassMainActivityextends Activity {
Button
prevoius,next;
ImageViewimage;
@Override
protectedvoidonCreate(Bundle
savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
prevoius = (Button)
findViewById(R.id.button_previous);
next = (Button)
findViewById(R.id.button_next);
image = (ImageView) findViewById(R.id.imageView);
prevoius.setEnabled(false);
prevoius.setOnClickListener(newOnClickListener() {
@Override
publicvoidonClick(View v) {
// TODO Auto-generated
method stub
image.setImageResource(R.drawable.kitkat);
prevoius.setEnabled(false);
next.setEnabled(true);
}
});
next.setOnClickListener(newOnClickListener() {
@Override
publicvoidonClick(View v) {
// TODO Auto-generated
method stub
image.setImageResource(R.drawable.lolipopa);
next.setEnabled(false);
prevoius.setEnabled(true);
}
});
}
}
Activity_second.xml
<RelativeLayoutxmlns: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:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity">
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/hello_world"/>
<ImageView
android:id="@+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/textView1"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_below="@+id/textView1"
android:src="@drawable/lolipopn"/>
</RelativeLayout>
SecondActivity.java
importandroid.os.Bundle;
importandroid.app.Activity;
importandroid.view.Menu;
publicclassSecondActivityextends Activity {
@Override
protectedvoidonCreate(Bundle
savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_second);
}
@Override
publicbooleanonCreateOptionsMenu(Menu
menu) {
// Inflate the
menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.second, menu);
returntrue;
}
AndroidManifest
<?xmlversion="1.0"encoding="utf-8"?>
<manifestxmlns:android="http://schemas.android.com/apk/res/android"
package="com.swamys.splashscreen"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17"/>
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme">
<activity
android:name="com.swmys.splashscreen.MainActivity"
android:label="@string/app_name">
<intent-filter>
<actionandroid:name="android.intent.action.MAIN"/>
<categoryandroid:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<activity
android:name="com.swamys.splashscreen.SecondActivity"
android:label="@string/title_activity_second">
</activity>
</application>
No comments:
Post a Comment