LAYOUT MENU UTAMA
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/andro id"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<TextView
android:id="@+id/emas"
android:textColor="#FFFFFF"
android:text="Harga Emas "
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
<TextView
android:id="@+id/txtemas"
android:textColor="#FFFFFF"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/><TextView
android:id="@+id/nisab"
android:textColor="#FFFFFF"
android:text="Besar Nisab "
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
<TextView
android:id="@+id/txtnisab"
android:textColor="#FFFFFF"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
<Button android:id="@+id/profesi"
android:text="Zakat Profesi"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginRight="1dip"
android:width="250dip"/>
<Button android:id="@+id/niaga"
android:text="Zakat Perdagangan"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center" android:width="250dip"/>
</LinearLayout>
LAYOUT ZAKAT PROFESI
<?xml version="1.0" encoding="UTF-8"?>
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/
android"
android:id="@+id/scrollView"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TableLayout android:id="@+id/tableLayout1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:stretchColumns="0">
<TableRow>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Perhitungan zakat Profesi"
/>
</TableRow>
<TableRow>
<TextView android:text="Pendapatan / gaji perbulan(setelah dipotong pajak) :"
android:id="@+id/TextView01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</TableRow>
<TableRow>
<EditText android:text=""
android:id="@+id/txtGaji"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:inputType="numberSigned|numberDecimal"/>
</TableRow>
<TableRow>
<TextView
android:id="@+id/TextView01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Bonus pertahun:" />
</TableRow>
<TableRow>
<EditText android:text=""
android:id="@+id/txtBonus"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:inputType="numberSigned|numberDecimal"/>
</TableRow>
<TableRow>
<Button android:text="Hitung"
android:id="@+id/btnHitung"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:onClick="hitungZakat"/>
</TableRow>
<TableRow>
<TextView android:text="Jumlah zakat profesi yang wajib dibayarkan:"
android:id="@+id/TextView01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</TableRow>
<TableRow>
<EditText android:text=""
android:id="@+id/txtzakat"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:inputType="numberSigned|numberDecimal"
android:enabled="false"/>
</TableRow>
<TableRow>
<Button android:text="Kembali ke Menu"
android:id="@+id/btnBack"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:onClick="backtoMenu"/>
</TableRow>
</TableLayout>
</ScrollView>
LAYOUT ZAKAT PERDAGANGAN
<?xml version="1.0" encoding="UTF-8"?>
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/
android"
android:id="@+id/scrollView"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TableLayout android:id="@+id/tableLayout1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:stretchColumns="0">
<TableRow>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Perhitungan Zakat Perniagaan"/>
</TableRow>
<TableRow>
<TextView
android:id="@+id/TextView01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Total barang dagangan :" />
</TableRow>
<TableRow android:baselineAligned="false">
<EditText android:text=""
android:id="@+id/txtKekayaan"
android:inputType="numberSigned|numberDecimal"
android:width="120dip"
android:layout_height="match_parent"
android:layout_width="60dip"/>
</TableRow>
<TableRow>
<TextView android:text="Hutang :"
android:id="@+id/TextView01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</TableRow>
<TableRow>
<EditText android:text=""
android:id="@+id/txtHutang"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:inputType="numberSigned|numberDecimal"/>
</TableRow>
<TableRow>
<TextView android:text="Kepemilikan dalam(%) :"
android:id="@+id/TextView01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</TableRow>
<TableRow>
<EditText android:text=""
android:id="@+id/txtKepemilikan"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:inputType="numberSigned|numberDecimal"/>
</TableRow>
<TableRow>
<Button android:text="Hitung"
android:id="@+id/btnHitung"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:onClick="hitungNiaga"/>
</TableRow>
<TableRow>
<TextView android:text="Jumlah Bersih Harta Usaha :"
android:id="@+id/TextView03"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</TableRow>
<TableRow>
<EditText android:text=""
android:id="@+id/txtJmlBersih"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:editable="false"
android:enabled="false"/>
</TableRow>
<TableRow>
<TextView android:text="Jumlah zakat perdagangan yang wajib dibayarkan:"
android:id="@+id/TextView03"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</TableRow>
<TableRow>
<EditText android:text=""
android:id="@+id/txtJmlZakat"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:editable="false"
android:enabled="false"/>
</TableRow>
<TableRow>
<Button android:text="Kembali ke Menu"
android:id="@+id/btnBack"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:onClick="backtoMenu"/>
</TableRow>
</TableLayout>
</ScrollView>
Source Code Java
MENU package com.example.urlgrabber;
import java.io.IOException;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.util.EntityUtils;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
public class urlgrabber extends Activity {
/** Called when the activity is first created. */
private TextView txtemas;
private TextView txtnisab;
public Button niaga;
public Button profesi;
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState);
setContentView(R.layout.main);
txtemas = (TextView) findViewById(R.id.txtemas);
txtnisab = (TextView) findViewById(R.id.txtnisab);
Button profesi =
(Button)findViewById(R.id.profesi);
Button niaga =
(Button)findViewById(R.id.niaga);
profesi.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub Intent j = new Intent(urlgrabber.this, HitungProfesi.class);
j.putExtra("pesan",txtnisab.getText());
startActivity(j);
} });
niaga.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub Intent k = new Intent(urlgrabber.this, HitungNiaga.class);
k.putExtra("pesan",txtnisab.getText());
startActivity(k);
} });
String html = null;
try { html =
getURLHttpGet("http://kurs.dollar.web.id/harga-emas- hari-ini.php");
//html =
getURLHttpGet("http://www.emas24karat.com/news.asp");
} catch (IOException e) { e.printStackTrace();
}
parseHTML(html);
}
private void parseHTML(String html) { // TODO Auto-generated method stub
String[] parts, parts2;
// Ambil harga emas dollar.web.id parts=html.split("<td>");
parts2 = parts[1].split("</td>");
txtemas.setText(parts2[0].replace(".",""));
//Ambil emas dr emas24karat.com
//parts=html.split("<p align=\"right\">");
//parts2 = parts[1].split("</td>");
//String ambil =
(parts2[0].replace(" ",""));
//String awal = (ambil.substring(0, 3));
//String akhir = (ambil.substring(4));
//txtemas.setText(awal+akhir);
//String emas = txtemas.getText().toString();
long nisab1 =
Long.valueOf(txtemas.getText().toString());
long nisab2 = nisab1*85;
txtnisab.setText(String.valueOf(nisab2));
}
private String getURLHttpGet(String url) throws IOException {
// TODO Auto-generated method stub
HttpClient client = new DefaultHttpClient();
HttpGet request = new HttpGet(url);
HttpResponse response = client.execute(request);
String responseBody =
EntityUtils.toString(response.getEntity());
return responseBody;
} }
ZAKAT PROFESI
package com.example.urlgrabber;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
public class HitungProfesi extends Activity { private EditText txtGaji;
private EditText txtBonus;
private EditText txtzakat;
public Button btnHitung;
/**
* Method yang dipanggil pada saat applikaasi dijalankan
* */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.prof);
txtGaji = (EditText) findViewById(R.id.txtGaji);
txtBonus= (EditText) findViewById(R.id.txtBonus);
txtzakat= (EditText) findViewById(R.id.txtzakat);
btnHitung =
(Button)findViewById(R.id.btnHitung);
}
/**
* Method untuk Menghitung Luas Persegi panjang dipanggil pada saat button
* Hitung Luas diklik *
* @param view */
public void hitungZakat(View view) { try {
long gaji =
Integer.parseInt(txtGaji.getText().toString());
long bonus =
Integer.parseInt(txtBonus.getText().toString());
long jmlgajisetahun = gaji * 12;
long jmltotal = jmlgajisetahun + bonus ; Intent j = this.getIntent();
long nisab =
Long.valueOf((j.getStringExtra("pesan")));
if (jmltotal > nisab){
double zakat = (2.5 / 100) * jmltotal;
txtzakat.setEnabled(true);
txtzakat.setText("Rp."+String.valueOf(zakat));
}else{
Toast.makeText(this,"belum mencapai Nisab", Toast.LENGTH_LONG).show();
}
//finish();
} catch (Exception e) { e.printStackTrace();
} }
/**
* Method untuk menutup activity dan kembali ke menu
* @param view */
public void backtoMenu(View view){
finish();
} }
PZAKAT PERDAGANGAN package com.example.urlgrabber;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
public class HitungNiaga extends Activity { private EditText txtKekayaan;
private EditText txtHutang;
private EditText txtKepemilikan;
private EditText txtJmlBersih;
private EditText txtJmlZakat;
public Button btnHitung;
/**
* Method yang dipanggil pada saat applikaasi dijalankan
* */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.niaga);
//Zakatapp ambil =
((Zakatapp)getApplicationContext());
txtKekayaan = (EditText) findViewById(R.id.txtKekayaan);
txtHutang= (EditText) findViewById(R.id.txtHutang);
txtKepemilikan= (EditText) findViewById(R.id.txtKepemilikan);
txtJmlBersih= (EditText) findViewById(R.id.txtJmlBersih);
txtJmlZakat= (EditText) findViewById(R.id.txtJmlZakat);
btnHitung =
(Button)findViewById(R.id.btnHitung);
}
public void hitungNiaga(View view) { try {
if (txtKekayaan.getText().length() == 0) { Toast.makeText(this,"Silahkan isi Angka yang benar!", Toast.LENGTH_LONG).show();
return;
}
if (txtHutang.getText().length() == 0) { Toast.makeText(this,"Silahkan isi Angka yang benar!", Toast.LENGTH_LONG).show();
return;
}
if (txtKepemilikan.getText().length() == 0) {
Toast.makeText(this,"Silahkan isi Angka yang benar!", Toast.LENGTH_LONG).show();
return;
}
long kekayaan =
Integer.parseInt(txtKekayaan.getText().toString());
long hutang =
Integer.parseInt(txtHutang.getText().toString());
long kepemilikan =
Integer.parseInt(txtKepemilikan.getText().toString());
long jmlbersih =(
kepemilikan/100)*(kekayaan-hutang);
Intent k = this.getIntent();
long nisab =
Long.valueOf((k.getStringExtra("pesan")));
if (jmlbersih > nisab){
double zakat = (2.5 / 100) * jmlbersih;
txtJmlBersih.setEnabled(true);
txtJmlZakat.setEnabled(true);
txtJmlBersih.setText(String.valueOf("Rp
"+jmlbersih));
txtJmlZakat.setText("Rp.
"+String.valueOf(zakat));
}else{
Toast.makeText(this,"belum mencapai nisab", Toast.LENGTH_LONG).show();
}
//finish();
} catch (Exception e) { e.printStackTrace();
} }
/**
* Method untuk menutup activity dan kembali ke menu
* @param view */
public void backtoMenu(View view){
finish();
} }