“Aplikasi My
Profile”
Assalamualaikum.as.wb.
Disini
saya akan memberi sedikit ilmu cara membuat Aplikasi My Profile :D
==================================================================================
Pertama-tama untuk
membuat splash kita harus membuat dulu file xml nya, misal main.xml dalam
folder res > layout yang isinya :
==================================================================================
<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/menu" >
<TextView
android:id="@+id/editText1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@+id/textView1"
android:layout_alignParentRight="true"
android:layout_marginBottom="15dp"
android:ems="10"
android:text="Welcome To My
Profile"
android:textColor="#ffffff"
android:textSize="25dp"
/>
</RelativeLayout>
===================================================================
kemudian buatlah folder dengan nama "anim" pada
direktori > res , dalam folder anim buat file XML dengan nama, selamat.xml lalu sesuaikan dengan code berikut :
===================================================================
<?xml version="1.0" encoding="utf-8"?>
<set
xmlns:android="http://schemas.android.com/apk/res/android"
android:shareInterpolator="false">
<alpha
android:fromAlpha="0.0"
android:toAlpha="1.0"
android:duration="2500">
</alpha>
</set>
====================================================================
lalu buat class dengan nama Main.java dalam di direktori src > yansah.tugas.android
isi code berikut :
====================================================================
package yansah.tugas.android;
import android.app.Activity;
import android.os.Bundle;
import android.content.Intent;
import android.view.animation.Animation;
import android.view.animation.Animation.AnimationListener;
import android.view.animation.AnimationUtils;
import android.widget.TextView;
public class Main extends Activity {
/** Called when
the activity is first created. */
@Override
public void onCreate(Bundle
savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
startAnimating();
}
private void startAnimating(){
TextView
judul_splash = (TextView) findViewById(R.id.editText1);
Animation
anim1 = AnimationUtils.loadAnimation(this, R.anim.selamat);
judul_splash.startAnimation(anim1);
anim1.setAnimationListener(new
AnimationListener() {
@Override
public
void onAnimationStart(Animation animation) {
//
TODO Auto-generated method stub
}
@Override
public
void onAnimationRepeat(Animation animation) {
//
TODO Auto-generated method stub
}
@Override
public
void onAnimationEnd(Animation animation) {
//
TODO Auto-generated method stub
startActivity(new
Intent(Main.this, menu.class));
Main.this.finish();
}
});
}
}
jika
tidak ter jadi error ketika dirun hasilnya akan seperti ini :
========================================================================
selanjutnya kita akan membuat menu , disini
saya akan membuat menu pada menu.xml cara nya dengan membuat class activity
pada src>> yansah.tugas.android misal nama
activitynya Menu.java lalu isi code berikut :
========================================================================
package yansah.tugas.android;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.ImageView;
import android.app.ProgressDialog;
public class menu extends Activity {
protected ImageView
profile;
protected ImageView
future;
protected
ProgressDialog pd1;
protected ImageView
exit;
/** Called when the activity
is first created. */
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
pd1 =
ProgressDialog.show(menu.this, "Please Wait...", "System is
loading module");
new Thread(){
public void run(){
try{
sleep(1000);
}
catch (Exception e){
Log.e("tag", e.getMessage());
}
pd1.dismiss();
}
} .start();
setContentView(R.layout.menu);
future =
(ImageView)findViewById(R.id.imageView2);
future.setOnClickListener(new
View.OnClickListener() {
@Override
public
void onClick(View v) {
//
TODO Auto-generated method stub
gantihalaman2();
}
});
profile =
(ImageView)findViewById(R.id.imageView1);
profile.setOnClickListener(new
View.OnClickListener() {
@Override
public
void onClick(View v) {
//
TODO Auto-generated method stub
gantihalaman();
}
});
exit = (ImageView)
findViewById(R.id.imageView3);
exit.setOnClickListener(new
View.OnClickListener() {
@Override
public
void onClick(View v) {
//
TODO Auto-generated method stub
keluar();
}
});
}
public void keluar(){
finish();
System.exit(0);
}
public void gantihalaman(){
Intent gh = new Intent(this,
profile.class);
startActivity(gh);
}
public void gantihalaman2(){
Intent gh2 = new Intent(this, future.class);
startActivity(gh2);
}
}
Maka hasilnya akan seperti yg di bawah ini :
=======================================================================
kemudian
code untuk halaman yang muncul ketika button di klik adalah ini :
profile.xml
profile.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/profile1" >
<TextView
android:id="@+id/editText1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:gravity="center"
android:text="MY
PROFILE"
android:layout_marginTop="20dp"
android:textColor="#ffffff"
android:textSize="25dp" />
<ImageView
android:id="@+id/imageView1"
android:layout_width="130dp"
android:layout_height="130dp"
android:layout_gravity="center"
android:layout_marginTop="20dp"
android:src="@drawable/asaa" />
<TextView
android:id="@+id/editText1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:layout_marginTop="25dp"
android:textSize="15dp"
android:text="Nama : Juliansyah"
android:textColor="#ffffff"
/>
<TextView
android:id="@+id/editText1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:layout_marginTop="5dp"
android:textSize="15dp"
android:text="Npm : 10215411109"
android:textColor="#ffffff"
/>
<TextView
android:id="@+id/editText1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:layout_marginTop="5dp"
android:textSize="15dp"
android:text="TTL : Bogor, 27 Juli 1992"
android:textColor="#ffffff"
/>
<TextView
android:id="@+id/editText1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:layout_marginTop="5dp"
android:textSize="15dp"
android:text="E-mail :
Kesilaek.yanzah7@gmail.com"
android:textColor="#ffffff"
/>
<TextView
android:id="@+id/editText1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:layout_marginTop="5dp"
android:textSize="15dp"
android:text="No.Tlpn : 085778117292"
android:textColor="#ffffff"
/>
<ImageView
android:id="@+id/imageback1"
android:layout_width="74dp"
android:layout_height="74dp"
android:src="@drawable/back" />
</LinearLayout>
===============================================================
Terus
jangan lupa untuk membuat Profile.java nya :
===============================================================
===============================================================
package yansah.tugas.android;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
public class profile extends Activity {
/** Called when
the activity is first created. */
@Override
public void
onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.profile);
ImageView
prof_kem = (ImageView)findViewById(R.id.imageback1);
prof_kem.setOnClickListener(new View.OnClickListener() {
@Override
public
void onClick(View v) {
//
TODO Auto-generated method stub
gantihalaman();
}
});
}
public void
gantihalaman(){
Intent gh = new
Intent(this, menu.class);
startActivity(gh);
}
}
Maka hasilnya seperti ini :
================================================================
Sekarang yang terakhir membuat rencana masa depan, hampir sama
seperti bikin profile,
Bikin future.xml code nya di bawah ini :
================================================================
<?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/profile1">
<TextView
android:id="@+id/editText1"
android:layout_width="match_parent"
android:text="FUTURE"
android:textColor="#ffffff"
android:gravity="center"
android:textSize="25dp"
android:layout_height="wrap_content"
android:ems="10" />
<TextView
android:id="@+id/editText1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:text="1.
Membahagiakan Orang Tua"
android:textColor="#ffffff"
android:layout_marginTop="30dp"
android:textSize="15dp"
/>
<TextView
android:id="@+id/editText1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:layout_marginTop="5dp"
android:textSize="15dp"
android:text="2.
Memberangkatkan Orang Tua naik Haji"
android:textColor="#ffffff"
/>
<TextView
android:id="@+id/editText1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:layout_marginTop="5dp"
android:textSize="15dp"
android:text="3. Kerja di microsoft,
haha amin :D"
android:textColor="#ffffff"
/>
<TextView
android:id="@+id/editText1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:layout_marginTop="5dp"
android:textSize="15dp"
android:text="4. Punya Rumah
sendiri"
android:textColor="#ffffff"
/>
<TextView
android:id="@+id/editText1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:layout_marginTop="5dp"
android:textSize="15dp"
android:text="5.
Menikah"
android:textColor="#ffffff"
/>
<TextView
android:id="@+id/editText1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:layout_marginTop="5dp"
android:textSize="15dp"
android:text="6. Naik HAJI,
aminn :)"
android:textColor="#ffffff"
/>
<ImageView
android:id="@+id/imageback2"
android:layout_width="74dp"
android:layout_height="74dp"
android:layout_marginTop="140dp"
android:src="@drawable/back" />
</LinearLayout> <?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/profile1">
<TextView
android:id="@+id/editText1"
android:layout_width="match_parent"
android:text="FUTURE"
android:textColor="#ffffff"
android:gravity="center"
android:textSize="25dp"
android:layout_height="wrap_content"
android:ems="10" />
<TextView
android:id="@+id/editText1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:text="1.
Membahagiakan Orang Tua"
android:textColor="#ffffff"
android:layout_marginTop="30dp"
android:textSize="15dp"
/>
<TextView
android:id="@+id/editText1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:layout_marginTop="5dp"
android:textSize="15dp"
android:text="2.
Memberangkatkan Orang Tua naik Haji"
android:textColor="#ffffff"
/>
<TextView
android:id="@+id/editText1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:layout_marginTop="5dp"
android:textSize="15dp"
android:text="3. Kerja di microsoft,
haha amin :D"
android:textColor="#ffffff"
/>
<TextView
android:id="@+id/editText1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:layout_marginTop="5dp"
android:textSize="15dp"
android:text="4. Punya Rumah
sendiri"
android:textColor="#ffffff"
/>
<TextView
android:id="@+id/editText1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:layout_marginTop="5dp"
android:textSize="15dp"
android:text="5.
Menikah"
android:textColor="#ffffff"
/>
<TextView
android:id="@+id/editText1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:layout_marginTop="5dp"
android:textSize="15dp"
android:text="6. Naik HAJI,
aminn :)"
android:textColor="#ffffff"
/>
<ImageView
android:id="@+id/imageback2"
android:layout_width="74dp"
android:layout_height="74dp"
android:layout_marginTop="140dp"
android:src="@drawable/back" />
</LinearLayout>
===========================================================
Lalu bikin Future.java :
===========================================================
package yansah.tugas.android;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import
android.widget.ImageView;
public class future extends
Activity {
/** Called when the activity is first
created. */
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.future);
ImageView prof_kem =
(ImageView)findViewById(R.id.imageback2);
prof_kem.setOnClickListener(new
View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
gantihalaman();
}
});
}
public void gantihalaman(){
Intent gh = new Intent(this, menu.class);
startActivity(gh);
}
}
Dan hasilnya seperti di bawah
ini :
Sekian dari saya atas
pembelajaran android hari ini . :D
disini saya akan kasih software my profile Gratiss !!
disini saya akan kasih software my profile Gratiss !!