Cara Buat Aplikasi Android Pengenalan Huruf Hijaiyah
Ini Adalah Source Code Untuk Play.java
package com.JayaMamonto.topimiring;
import android.app.Activity;
import android.media.MediaPlayer;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageButton;
public class Play extends Activity {
private MediaPlayer player;
ImageButton alif;
ImageButton ba;
ImageButton ta;
ImageButton tsa;
ImageButton jim;
ImageButton kha;
ImageButton kho;
ImageButton dal;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.play);
alif = (ImageButton) this.findViewById(R.id.alif);
ba = (ImageButton) this.findViewById(R.id.ba);
ta = (ImageButton) this.findViewById(R.id.ta);
tsa = (ImageButton) this.findViewById(R.id.tsa);
jim = (ImageButton) this.findViewById(R.id.jim);
kha = (ImageButton) this.findViewById(R.id.kha);
kho = (ImageButton) this.findViewById(R.id.kho);
dal = (ImageButton) this.findViewById(R.id.dal);
alif.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
playSound(1);
}
});
ba.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
playSound(2);
}
});
ta.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
playSound(3);
}
});
tsa.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
playSound(4);
}
});
jim.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
playSound(5);
}
});
kha.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
playSound(6);
}
});
kho.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
playSound(7);
}
});
dal.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
playSound(8);
}
});
}
@Override
public void onPause() {
try {
super.onPause();
player.pause();
} catch (Exception e) {
}
}
private void playSound(int arg) {
try {
if (player.isPlaying()) {
player.stop();
player.release();
}
} catch (Exception e) {
}
if (arg == 1) {
player = MediaPlayer.create(this, R.raw.alif);
}
if (arg == 2) {
player = MediaPlayer.create(this, R.raw.ba);
}
if (arg == 3) {
player = MediaPlayer.create(this, R.raw.ta);
}
if (arg == 4) {
player = MediaPlayer.create(this, R.raw.tsa);
}
if (arg == 5) {
player = MediaPlayer.create(this, R.raw.jim);
}
if (arg == 6) {
player = MediaPlayer.create(this, R.raw.kha);
}
if (arg == 7) {
player = MediaPlayer.create(this, R.raw.kho);
}
if (arg == 8) {
player = MediaPlayer.create(this, R.raw.dal);
}
player.setLooping(false); // Set looping
player.start();
}
}
Ini Adalah Source Code Untuk Help.java
package com.JayaMamonto.topimiring;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
public class Help extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.help);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.help, menu);
return true;
}
}
Ini Adalah Source Code Untuk About.java
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
public class About extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.about);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.about, menu);
return true;
}
}
Ini Adalah Source Code Untuk Screen.java
import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.widget.ProgressBar;
public class Screen extends Activity{
private static final int SPLASH_TIME = 3 * 1000;// Set waktu 7 Detik
ProgressBar prg;
@SuppressLint("NewApi")
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.screen);//layout yang diload
prg = (ProgressBar)findViewById(R.id.progressBar1);//Tampilan progress Bar
prg.setAlpha(SPLASH_TIME);
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
Intent intent = new Intent(Screen.this,Menuawal.class);
startActivity(intent);
finish();
}
}, SPLASH_TIME);
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
}
}, SPLASH_TIME);
}
}
Ini Adalah Source Code Untuk Menuawal.java
import android.app.Activity;
import android.app.AlertDialog;
import android.app.AlertDialog.Builder;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
public class Menuawal extends Activity implements OnClickListener {
private Builder setNegativeButton;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.menuawal);
View pindah = findViewById(R.id.pindah);
pindah.setOnClickListener(this);
View info = findViewById(R.id.info);
info.setOnClickListener(this);
View keluar = findViewById(R.id.keluar);
keluar.setOnClickListener(this);
View help = findViewById(R.id.bantuan);
help.setOnClickListener(this);
}
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
switch (v.getId()) {
case R.id.pindah:
Intent pilihan = new Intent(this, Play.class);
startActivity(pilihan);
break;
case R.id.bantuan:
Intent help = new Intent(this, Help.class);
startActivity(help);
break;
case R.id.info:
Intent info = new Intent(this, About.class);
startActivity(info);
break;
case R.id.keluar:
AlertDialog.Builder mauKeluar = new AlertDialog.Builder(
Menuawal.this);
SetNegativeButton(mauKeluar
.setMessage("Anda yakin ingin keluar ?")
.setCancelable(false)
.setPositiveButton("Yes",
new AlertDialog.OnClickListener() {
@Override
public void onClick(DialogInterface arg0,
int arg1) {
finish();
}
})
.setNegativeButton("No", new AlertDialog.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.cancel();
}
}));
AlertDialog judul1 = mauKeluar.create();
judul1.setTitle("EXIT ?");
judul1.show();
break;
}
}
private void SetNegativeButton(Builder setNegativeButton2) {
// TODO Auto-generated method stub}
}
public Builder getSetNegativeButton() {
return setNegativeButton;
}
public void setSetNegativeButton(Builder setNegativeButton) {
this.setNegativeButton = setNegativeButton;
}
}
Selanjutnya Kita Buat Source Code Untuk File xmlnya Yaitu play.xml ini source code nya
<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/kosong"
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=".Play" >
<ImageButton
android:id="@+id/ba"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="@+id/alif"
android:layout_toLeftOf="@+id/alif"
android:src="@drawable/ba" />
<ImageButton
android:id="@+id/alif"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:src="@drawable/alif" />
<ImageButton
android:id="@+id/jim"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/alif"
android:layout_below="@+id/alif"
android:src="@drawable/jim" />
<ImageButton
android:id="@+id/kha"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/ba"
android:layout_toLeftOf="@+id/alif"
android:src="@drawable/kha" />
<ImageButton
android:id="@+id/tsa"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@+id/kha"
android:layout_toLeftOf="@+id/ta"
android:src="@drawable/tsa" />
<ImageButton
android:id="@+id/ta"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="@+id/ba"
android:layout_toLeftOf="@+id/ba"
android:src="@drawable/ta" />
<ImageButton
android:id="@+id/kho"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/tsa"
android:layout_toRightOf="@+id/tsa"
android:src="@drawable/kho" />
<ImageButton
android:id="@+id/dal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/tsa"
android:layout_toLeftOf="@+id/ta"
android:src="@drawable/dal" />
</RelativeLayout>
Ini Adalah Source Code Untuk help.xml
<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/bantuan"
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=".Help" >
</RelativeLayout>
Ini Adalah Source Code Untuk about.xml
<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/tentang"
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=".About" >
</RelativeLayout>
Ini Adalah Source Code Untuk screen.xml
<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/splash"
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=".Screen" >
<FrameLayout
android:id="@+id/FrameLayout1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true" >
<ProgressBar
android:layout_gravity="center"
android:id="@+id/progressBar1"
style="?android:attr/progressBarStyleLarge"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</FrameLayout>
</RelativeLayout>
Ini Adalah Source Code Untuk menuawal.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/bg"
android:orientation="vertical"
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=".Menuawal" >
<ImageButton
android:id="@+id/info"
android:layout_width="100dip"
android:layout_height="100dip"
android:layout_above="@+id/bantuan"
android:layout_alignParentRight="true"
android:layout_marginRight="29dp"
android:textSize="15sp"
android:textStyle="bold"
android:src="@drawable/about" />
<ImageButton
android:id="@+id/keluar"
android:layout_width="100dip"
android:layout_height="100dip"
android:layout_alignBaseline="@+id/bantuan"
android:layout_alignBottom="@+id/bantuan"
android:layout_alignLeft="@+id/info"
android:textSize="15sp"
android:textStyle="bold"
android:src="@drawable/keluar" />
<ImageButton
android:id="@+id/bantuan"
android:layout_width="100dip"
android:layout_height="100dip"
android:layout_alignLeft="@+id/pindah"
android:layout_below="@+id/pindah"
android:layout_marginTop="38dp"
android:textSize="15sp"
android:textStyle="bold"
android:src="@drawable/help" />
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignRight="@+id/pindah"
android:layout_below="@+id/pindah"
android:layout_marginRight="26dp"
android:text="PLAY"
android:textStyle="bold"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/textView1"
android:layout_alignBottom="@+id/textView1"
android:layout_alignRight="@+id/info"
android:layout_marginRight="19dp"
android:text="ABOUT"
android:textStyle="bold"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/textView1"
android:layout_below="@+id/bantuan"
android:text="HELP"
android:textStyle="bold"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="@+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/textView3"
android:layout_alignBottom="@+id/textView3"
android:layout_alignLeft="@+id/textView2"
android:text="EXIT ?"
android:textStyle="bold"
android:textAppearance="?android:attr/textAppearanceMedium" />
<ImageButton
android:id="@+id/pindah"
android:layout_width="100dip"
android:layout_height="100dip"
android:layout_alignParentTop="true"
android:layout_marginRight="35dp"
android:layout_marginTop="46dp"
android:layout_toLeftOf="@+id/info"
android:src="@drawable/play"
android:textSize="15sp"
android:textStyle="bold" />
</RelativeLayout>
Dan Ini Adalah Hasil Running Dari Source DI Atas
Hasil Awal
Hasil Kedua
Hasil Ketiga
Komentar
Posting Komentar