Reservasi Tiket Bus Online
Dimana kita tidak usah mengantri untuk membeli Tiket Baik di Pool Bus maupun Terminal Bus
- coding login 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"
tools:context=".MainActivity" >
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@+id/textView1"
android:layout_marginTop="28dp"
android:text="USER" />
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginLeft="54dp"
android:layout_marginTop="21dp"
android:layout_toRightOf="@+id/textView2"
android:text="LOGIN" />
<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@+id/textView2"
android:layout_marginTop="44dp"
android:text="PASSWORD" />
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_marginLeft="31dp"
android:text="MASUK" />
<Button
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/button1"
android:layout_alignBottom="@+id/button1"
android:layout_toRightOf="@+id/textView1"
android:text="KELUAR" />
<EditText
android:id="@+id/editText1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/textView2"
android:layout_alignBottom="@+id/textView2"
android:layout_marginLeft="28dp"
android:layout_toRightOf="@+id/textView2"
android:ems="10" >
<requestFocus />
</EditText>
<EditText
android:id="@+id/editText2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/textView3"
android:layout_alignBottom="@+id/textView3"
android:layout_alignLeft="@+id/editText1"
android:ems="10"
android:inputType="textPassword" />
</RelativeLayout>
dengan hasil tampilan
- coding login java
import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
public class MainActivity extends Activity {
EditText userNameTxt;
EditText passwordTxt;
Button loginBtn;
Button tutupBtn;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
userNameTxt = (EditText) findViewById(R.id.editText1);
passwordTxt = (EditText) findViewById(R.id.editText2);
loginBtn = (Button) findViewById(R.id.button1);
tutupBtn = (Button) findViewById(R.id.button2);
loginBtn.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
Intent i = new Intent(MainActivity.this, SuccessActivity.class);
i.putExtra(“pesan”, “Sukses Login”);
startActivity(i);
}
});
tutupBtn.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
moveTaskToBack(true);
android.os.Process.killProcess(android.os.Process.myPid());
System.exit(0);
}
});
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.activity_main, menu);
return true;
}
}
- coding xml tiket
<?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" >
<LinearLayout
android:id="@+id/linearLayout1"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Nama " />
<EditText
android:id="@+id/ednama"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.96" >
<requestfocus />
</EditText>
</LinearLayout>
<LinearLayout
android:id="@+id/linearLayout2"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Alamat " />
<EditText
android:id="@+id/edalamat"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1" />
</LinearLayout>
<LinearLayout
android:id="@+id/linearLayout3"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Tujuan " />
<EditText
android:id="@+id/edtujuan"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1" />
</LinearLayout>
<TextView
android:id="@+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Kelas" />
<RadioGroup
android:id="@+id/Rgkelas"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<RadioButton
android:id="@+id/rbekonomi"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="true"
android:text="Ekonomi" />
<RadioButton
android:id="@+id/Rbvip"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="VIP" />
</RadioGroup>
<TextView
android:id="@+id/Tvharga"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Service" />
<CheckBox
android:id="@+id/Cbmeal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Onboard Meal" />
<CheckBox
android:id="@+id/Cbdrink"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Onboard Drink" />
<Button
android:id="@+id/button1"
android:onClick="hitungbiaya"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:onClick="hitungbiaya"
android:text="Hitung" />
</LinearLayout>
<linearlayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<LinearLayout
android:id="@+id/linearLayout1"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Nama " />
<EditText
android:id="@+id/ednama"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.96" >
<requestfocus />
</EditText>
</LinearLayout>
<LinearLayout
android:id="@+id/linearLayout2"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Alamat " />
<EditText
android:id="@+id/edalamat"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1" />
</LinearLayout>
<LinearLayout
android:id="@+id/linearLayout3"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Tujuan " />
<EditText
android:id="@+id/edtujuan"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1" />
</LinearLayout>
<TextView
android:id="@+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Kelas" />
<RadioGroup
android:id="@+id/Rgkelas"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<RadioButton
android:id="@+id/rbekonomi"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="true"
android:text="Ekonomi" />
<RadioButton
android:id="@+id/Rbvip"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="VIP" />
</RadioGroup>
<TextView
android:id="@+id/Tvharga"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Service" />
<CheckBox
android:id="@+id/Cbmeal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Onboard Meal" />
<CheckBox
android:id="@+id/Cbdrink"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Onboard Drink" />
<Button
android:id="@+id/button1"
android:onClick="hitungbiaya"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:onClick="hitungbiaya"
android:text="Hitung" />
</LinearLayout>
- coding java tiketing
package program.;Muhammad_anwar
import android.app.Activity;
import android.os.Bundle;
import program.Pesan.tiket.;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;;
import android.widget.RadioGroup;
import android.widget.CheckBox;
import java.util.List;
import java.text.NumberFormat;
import java.text.DecimalFormat;
import android.widget.ArrayAdapter;
public class PESAN_TIKET extends Activity {
int hargatiket,biayakelas,biayasrvicemakan,biayaserviceminum;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_pesan__tiket);
}
public void hitungbiaya(View v){
EditText nama = (EditText)findViewById(R.id.ednama);
String Nama = nama.getText().toString();
EditText tujuan = (EditText) findViewById(R.id.edtujuan);
String Tujuan = tujuan.getText().toString();
if ("Jakarta".equals(Tujuan))
{
hargatiket= 800000;
}
else if("Batam".equals(Tujuan))
{
hargatiket= 500000;
}
else if("Padang".equals(Tujuan))
{
hargatiket= 350000;
}
//Kelas
RadioGroup kelas = (RadioGroup)findViewById(R.id.rgkelas);
int kls = kelas.getCheckedRadioButtonId();
if (kls == R.id.rbvip){
biayakelas=500000;
}else
if (kls == R.id.rbekonomi){
biayakelas=0;
}
//Service
CheckBox servismakan = (CheckBox)findViewById(R.id.cbmakan);
if (servismeal.isChecked()){
biayaservicemakan = 30000;
}else
{
biayaservicemeal = 0;
}
CheckBox servisminum = (CheckBox)findViewById(R.id.chminum);
if (servisminum.isChecked()){
biayaserviceminum = 20000;
}else
{
biayaserviceminum = 0;
}
int totalbiaya = hargatiket+biayakelas+biayaservicemakan+biayaserviceminum;
NumberFormat numberFormat = new DecimalFormat("#,###,###");
String str = numberFormat.format(totalbiaya);
TextView totalharga = (TextView)findViewById(R.id.tvharga);
totalharga.setText("Harga Tiket Bpk/Ibu. "+Nama.toString() + " Rp."+ str);
}
}
import android.app.Activity;
import android.os.Bundle;
import program.Pesan.tiket.;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;;
import android.widget.RadioGroup;
import android.widget.CheckBox;
import java.util.List;
import java.text.NumberFormat;
import java.text.DecimalFormat;
import android.widget.ArrayAdapter;
public class PESAN_TIKET extends Activity {
int hargatiket,biayakelas,biayasrvicemakan,biayaserviceminum;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_pesan__tiket);
}
public void hitungbiaya(View v){
EditText nama = (EditText)findViewById(R.id.ednama);
String Nama = nama.getText().toString();
EditText tujuan = (EditText) findViewById(R.id.edtujuan);
String Tujuan = tujuan.getText().toString();
if ("Jakarta".equals(Tujuan))
{
hargatiket= 800000;
}
else if("Batam".equals(Tujuan))
{
hargatiket= 500000;
}
else if("Padang".equals(Tujuan))
{
hargatiket= 350000;
}
//Kelas
RadioGroup kelas = (RadioGroup)findViewById(R.id.rgkelas);
int kls = kelas.getCheckedRadioButtonId();
if (kls == R.id.rbvip){
biayakelas=500000;
}else
if (kls == R.id.rbekonomi){
biayakelas=0;
}
//Service
CheckBox servismakan = (CheckBox)findViewById(R.id.cbmakan);
if (servismeal.isChecked()){
biayaservicemakan = 30000;
}else
{
biayaservicemeal = 0;
}
CheckBox servisminum = (CheckBox)findViewById(R.id.chminum);
if (servisminum.isChecked()){
biayaserviceminum = 20000;
}else
{
biayaserviceminum = 0;
}
int totalbiaya = hargatiket+biayakelas+biayaservicemakan+biayaserviceminum;
NumberFormat numberFormat = new DecimalFormat("#,###,###");
String str = numberFormat.format(totalbiaya);
TextView totalharga = (TextView)findViewById(R.id.tvharga);
totalharga.setText("Harga Tiket Bpk/Ibu. "+Nama.toString() + " Rp."+ str);
}
}
Tidak ada komentar:
Posting Komentar