.: MEMBUAT MY BIODATA :.
Android tidak beda jauh dengan aplikasi-aplikasi lainnya. Android yang menerapkan bahasa pemrograman java memiliki class-class yang sangat lengkap dari yang lebih kompleks hingga yang paling sederhana.
Untuk memulai pemrograman, kita mencoba membuat MY BIODATA diandroid.
“MY BIODATA” menampilkan splash screen, loading, halaman dan tulisan.
Disini kita membutuhkan beberapa file XML layout dan file java untuk membukanya. File-file yang lain sudah disiapkan oleh eclipse yang telah menggunakan Android-ADT, seperti file AndroidManifest.xml yang paling penting. Perlu dipahami, aplikasi android pada umumnya dalam pembuatannya selalu membutuhkan file XML yang digunakan untuk menentukan layout tampilan aplikasi android dan file java yang akan menjalankan program.
Oke langsung aja yu kita praktekkan, pada MY BIODATA.
- Langkah-langkahnya sebagai berikut :
1. buat projeknya file > new > project
Masukkan nama dalam inputanya seperti ini:
Projek name : tugas android
Build target : 2.2
Application name : tugas android
Package name : com.tia.andoid
Minimum SDK : API 8
2. setelah project tercreate maka secara otomatis android membentuk 3 file yaitu :
- main.xml
- string.xml
- TugasandroidActivity.java
Tetapi kita masih membutuhkan 3 file xml dan 3 file java
3. kita buat beberapa activity lagi, disini kita akan membuat 3 file xml :
- profil.xml
- masadepan.xml
- animasi.xml
- klik kanan pada layout new > Android XML File)
- beri nama pada file > finish
Gambar 1. tampilan menambah file .xml
4. untuk membuat file xml ulangi lagkah no.3.
5. kita membuat beberapa file java lagi, disini kita menambahkan 3 file java :
· PROFIL.java
· Masadepan.java
· Animasi_activity.java
a) Klik kanan pada com.tia.android.activity > new > class
b) Beri nama pada file > finish
gambar 2. tampilan membuat file .java
5. untuk membuat class lagi ulangi lagi cara no.4
************************************************************************************************************************
-> SPLASH SCREEN
- animasi_activity.java
package com.tia.android.activity;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.view.animation.Animation.AnimationListener;
import android.view.animation.LayoutAnimationController;
import android.widget.TableLayout;
import android.widget.TableRow;
import android.widget.TextView;
public class animasi_activity extends Activity{
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.animasi);
startAnimating();
}
private void startAnimating() {
// TODO Auto-generated method stub
TextView judul = (TextView) findViewById(R.id.judul);
Animation fade1 = AnimationUtils.loadAnimation(this, R.anim.fade_in);
judul.startAnimation(fade1);
TextView isi = (TextView) findViewById(R.id.isi);
Animation fade2 = AnimationUtils.loadAnimation(this, R.anim.fade_in2);
isi.startAnimation(fade2);
fade2.setAnimationListener(new AnimationListener() {
public void onAnimationStart(Animation animation) {
// TODO Auto-generated method stub
}
public void onAnimationRepeat(Animation animation) {
// TODO Auto-generated method stub
}
public void onAnimationEnd(Animation animation) {
// TODO Auto-generated method stub
startActivity(new Intent(animasi_activity.this, TugasandroidActivity.class));
animasi_activity.this.finish();
}
});
Animation spinin = AnimationUtils.loadAnimation(this, R.anim.custom_anim);
LayoutAnimationController controller = new LayoutAnimationController(spinin);
TableLayout tabel = (TableLayout) findViewById(R.id.tabel);
TableRow row = (TableRow) tabel.getChildAt(0);
row.setLayoutAnimation(controller);
}
}
2. animasi.xml
<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/bnr"
android:id="@+id/tabel">
<TableRow android:gravity="center">
<TextView
android:id="@+id/judul"
android:textSize="30dp"
android:text=".: WELCOME :."
android:textColor="#0a6db3"
android:layout_gravity="center"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:paddingTop="20dp"
android:textStyle="bold"
android:layout_marginLeft="10dp"/>
</TableRow>
<TableRow android:gravity="center">
<TextView
android:id="@+id/isi"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="MY BIODATA"
android:layout_gravity="center"
android:textColor="#0a6db3"
android:textSize="20dp"
android:paddingTop="30dp"
android:textStyle="bold"
android:layout_marginLeft="10dp"/>
</TableRow>
<TableRow android:gravity="center" >
</TableRow>
<TextView
android:id="@+id/cp"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="copyright yuliastia"
android:layout_marginTop="320dp"
android:gravity="center"
android:textColor="#0a6db3"
android:textSize="10dp"
android:textStyle="bold"
android:layout_marginLeft="10dp" />
</TableLayout>
tampilan splash screen
********************************************************************************************************************
-> TAMPILAN MENU UTAMA DAN BUTTON EXIT
1) TugasandroidActivity.java
package com.tia.android.activity;
import android.os.Bundle;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.ProgressDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageButton;
import android.view.KeyEvent;
public class TugasandroidActivity extends Activity {
protected ProgressDialog progressDialog;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
ImageButton exit = (ImageButton)findViewById(R.id.exit);
exit.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
close();
}
});
}
public void PROFIL (View view) {
Intent intent1=new Intent (this,PROFIL.class);
startActivity(intent1);
}
public void MasaDepan (View view) {
Intent intent2=new Intent (this,Masadepan.class);
startActivity(intent2);
}
public void close(){
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setMessage("Do you really want to exit in my biodata?")
.setCancelable(false)
.setPositiveButton("Yes",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,
int id) {
TugasandroidActivity.this.finish();
}
})
.setNegativeButton("No",new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,
int id) {
dialog.cancel();
}
}).show();
}
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACKSLASH) {
close();
}
return super.onKeyDown(keyCode, event);
}
}
2) main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:background="@drawable/blue" >
<TextView
android:id="@+id/menu"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:layout_marginTop="25dp"
android:text="MENU"
android:textColor="#0a6db3"
android:textSize="10pt"
android:textStyle="bold"/>
<ImageButton
android:src="@drawable/profil"
android:id="@+id/prof"
android:layout_width="100dp"
android:layout_height="50dp"
android:layout_gravity="center_vertical"
android:layout_marginTop="70dp"
android:onClick="PROFIL"/>
<ImageButton
android:src="@drawable/ms"
android:id="@+id/mds"
android:layout_width="146dp"
android:layout_height="62dp"
android:layout_gravity="center_horizontal"
android:layout_marginTop="50dp"
android:onClick="MasaDepan"/>
<ImageButton
android:src="@drawable/exit"
android:id="@+id/exit"
android:layout_width="92dp"
android:layout_height="45dp"
android:layout_marginTop="50dp"
android:layout_gravity="right|center_vertical"
android:onClick="exit"/>
</LinearLayout>
tampilan menu utama
tampilan exit
*******************************************************************************************************************
-> PROFIL DAN SYSTEM LOADING
1) PROFIL.java
package com.tia.android.activity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Intent;
public class PROFIL extends Activity {
protected ProgressDialog progressDialog;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
progressDialog = ProgressDialog.show(PROFIL.this,"Please Wait . . .", "System is Loading");
new Thread(){
public void run() {
try{
sleep(4000);
}
catch (Exception e) {
Log.e("tag",e.getMessage());
}
progressDialog.dismiss();
}
}.start();
setContentView(R.layout.profil);
}
public void Back2 (View view) {
Intent intent3 = new Intent (this, TugasandroidActivity.class);
startActivity (intent3);
}
}
2) Profil.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="@drawable/tia">
<TextView
android:id="@+id/biod"
android:text="PROFIL"
android:textColor="#0460f9"
android:layout_gravity="center"
android:textStyle="bold"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="23dp"
android:layout_marginTop="10dp"/>
<ImageView
android:src="@drawable/ia"
android:layout_width="85dp"
android:layout_height="100dp"
android:layout_marginTop="10dp"
android:layout_gravity="center"/>
<TextView
android:id="@+id/nm"
android:text="Nama : Yuliastia"
android:textColor="#0460f9"
android:textSize="15dp"
android:textStyle="normal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:layout_marginRight="43dp"
android:layout_marginLeft="43dp"
android:layout_gravity="left"/>
<ImageButton
android:id="@+id/back2"
android:layout_width="70dp"
android:layout_height="48dp"
android:layout_marginTop="69dp"
android:onClick="Back2"
android:src="@drawable/wlp"
android:layout_gravity="center"/>
</LinearLayout>
tampilan loading
tampilan profil
********************************************************************************************************************
-> TAMPILAN MASA DEPAN
1) Masadepan.java
package com.tia.android.activity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Intent;
public class Masadepan extends Activity {
protected ProgressDialog progressDialog;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
progressDialog = ProgressDialog.show(Masadepan.this,"Please Wait . . .", "System is Loading");
new Thread(){
public void run() {
try{
sleep(4000);
}
catch (Exception e) {
Log.e("tag",e.getMessage());
}
progressDialog.dismiss();
}
}.start();
setContentView(R.layout.masadepan);
}
public void Back (View view) {
Intent intent1=new Intent (this, TugasandroidActivity.class);
startActivity (intent1);
}
}
2) masadepan.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="@drawable/images">
<TextView
android:id="@+id/md"
android:text="Rencana"
android:textColor="#0460f9"
android:layout_gravity="center"
android:textStyle="bold"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="23dp"
android:typeface="serif"
android:layout_marginTop="10dp"/>
<TextView
android:id="@+id/tulisan"
android:text="1. lulus kuliah semester 8"
android:textColor="#0460f9"
android:textSize="15dp"
android:textStyle="normal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:layout_marginRight="9dp"
android:layout_marginLeft="9dp"/>
<ImageButton
android:src="@drawable/back"
android:layout_width="70dp"
android:layout_height="48dp"
android:id="@+id/back"
android:onClick="Back"
android:layout_gravity="center"
android:layout_marginTop="69dp"/>
</LinearLayout>\
tampilan rencana
************************************************************************************************************
-> String.xml
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<resources>
<string name="hello">Hello World, TugasandroidActivity!</string>
<string name="app_name">Tugas android</string>
<string name="biod">Profil Saya</string>
<string name="md">Masa depan saya</string>
<string name="ani">Welcome</string>
</resources>
********************************************************************************************************************
-> AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.tia.android.activity"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="8" />
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<activity android:name=".animasi_activity"
android:label="@string/ani">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".TugasandroidActivity"
android:label="@string/app_name" >
</activity>
<activity
android:name=".PROFIL"
android:label="@string/biod">
</activity>
<activity
android:name=".Masadepan"
android:label="@string/md">
</activity>
</application>
</manifest>
---------------------------------------------------------------------------------------------------------------------------------------------------
untuk donwload APKnya klik dibawah ini :
.: selamat mencoba :) :.