Membuat aplikasi tiketing sederhana di Android
aplikasi ini irancang untuk mempermudah dalam melakukan pemesanan tiket yang akan dibeli seperti pemesanan tiket bus, kereta dll
untuk itu mari kita ikuti langkah-langkah berikut:
1. Pertama Klik New-New Projek seperti gambar di bawah ini.
3. klik finish
4. design seperti gambar berikut..
berikut coding xmlnya..
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
tools:context=".MainActivity">
<EditText
android:id="@+id/nama"
android:layout_width="350dp"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginLeft="16dp"
android:layout_marginTop="29dp"
android:layout_marginEnd="8dp"
android:layout_marginRight="8dp"
android:layout_marginBottom="657dp"
android:autofillHints=""
android:ems="10"
android:hint="Masukan Nama"
android:inputType="textPersonName"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.0" />
<TextView
android:id="@+id/textView3"
android:layout_width="119dp"
android:layout_height="30dp"
android:layout_marginStart="17dp"
android:layout_marginLeft="17dp"
android:layout_marginTop="11dp"
android:layout_marginBottom="499dp"
android:text="Jurusan"
android:textColor="#0A0A0A"
android:textSize="18sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/nama"
app:layout_constraintVertical_bias="0.8" />
<RadioGroup
android:id="@+id/radioGroup"
android:layout_width="350dp"
android:layout_height="75dp"
android:layout_marginStart="6dp"
android:layout_marginLeft="6dp"
android:layout_marginTop="7dp"
android:layout_marginEnd="18dp"
android:layout_marginRight="18dp"
android:layout_marginBottom="426dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textView3">
<RadioButton
android:id="@+id/radiosolo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="SOLO" />
<RadioButton
android:id="@+id/radiojogja"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="JOGJA" />
<RadioButton
android:id="@+id/radiowonogiri"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="WONOGIRI" />
</RadioGroup>
<TextView
android:id="@+id/textView4"
android:layout_width="200dp"
android:layout_height="25dp"
android:layout_marginStart="16dp"
android:layout_marginLeft="16dp"
android:layout_marginTop="12dp"
android:layout_marginEnd="323dp"
android:layout_marginRight="323dp"
android:layout_marginBottom="390dp"
android:text="Class"
android:textColor="#1A1315"
android:textSize="18sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/radioGroup"
app:layout_constraintVertical_bias="1.0" />
<TextView
android:id="@+id/textView5"
android:layout_width="200dp"
android:layout_height="25dp"
android:layout_marginStart="16dp"
android:layout_marginLeft="16dp"
android:layout_marginTop="12dp"
android:layout_marginEnd="323dp"
android:layout_marginRight="323dp"
android:layout_marginBottom="390dp"
android:text="Class"
android:textColor="#1A1315"
android:textSize="18sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/radioGroup"
app:layout_constraintVertical_bias="1.0" />
<RadioGroup
android:id="@+id/radioGroup2"
android:layout_width="350dp"
android:layout_height="50dp"
android:layout_marginStart="26dp"
android:layout_marginLeft="26dp"
android:layout_marginTop="225dp"
android:layout_marginEnd="395dp"
android:layout_marginRight="395dp"
android:layout_marginBottom="377dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.19">
<RadioButton
android:id="@+id/radioexe"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="EXECUTIVE" />
<RadioButton
android:id="@+id/radiovip"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="VIP" />
</RadioGroup>
<EditText
android:id="@+id/banyak"
android:layout_width="350dp"
android:layout_height="40dp"
android:layout_marginStart="16dp"
android:layout_marginLeft="16dp"
android:layout_marginTop="1dp"
android:layout_marginEnd="181dp"
android:layout_marginRight="181dp"
android:layout_marginBottom="228dp"
android:ems="10"
android:hint="Jumlah Tiket"
android:inputType="textPersonName"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.007"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/radioGroup2"
app:layout_constraintVertical_bias="0.0" />
<TextView
android:id="@+id/textView6"
android:layout_width="200dp"
android:layout_height="25dp"
android:layout_marginStart="17dp"
android:layout_marginLeft="17dp"
android:layout_marginEnd="336dp"
android:layout_marginRight="336dp"
android:layout_marginBottom="278dp"
android:text="Harga"
android:textColor="#291D1D"
android:textSize="18sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/banyak"
app:layout_constraintVertical_bias="1.0" />
<Button
android:id="@+id/cetak"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="46dp"
android:layout_marginLeft="46dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="60dp"
android:layout_marginRight="60dp"
android:layout_marginBottom="241dp"
android:text="CETAK"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/textView6"
app:layout_constraintTop_toBottomOf="@+id/banyak" />
<EditText
android:id="@+id/total"
android:layout_width="200dp"
android:layout_height="30dp"
android:layout_marginStart="17dp"
android:layout_marginLeft="17dp"
android:layout_marginTop="17dp"
android:layout_marginEnd="33dp"
android:layout_marginRight="33dp"
android:layout_marginBottom="217dp"
android:ems="10"
android:inputType="number"
android:textColor="#131011"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/cetak"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textView6"
app:layout_constraintVertical_bias="0.0" />
</android.support.constraint.ConstraintLayout>
dan hasilnya setelah di run
lalu masuk ke codingan MainActivity.java
package com.example.anggatianp_161021450122;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.RadioButton;
import android.widget.RadioGroup;
public class MainActivity extends AppCompatActivity {
EditText nama, banyak, total;
RadioGroup radioGroup, radioGroup2;
RadioButton solo, jogja, wonogiri, exe, vip;
Button cetak;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
nama = (EditText)findViewById(R.id.nama);
banyak = (EditText)findViewById(R.id.banyak);
total = (EditText)findViewById(R.id.total);
radioGroup = (RadioGroup)findViewById(R.id.radioGroup);
radioGroup2 = (RadioGroup)findViewById(R.id.radioGroup2);
solo = (RadioButton)findViewById(R.id.radiosolo);
jogja = (RadioButton)findViewById(R.id.radiojogja);
wonogiri = (RadioButton)findViewById(R.id.radiowonogiri);
exe = (RadioButton)findViewById(R.id.radioexe);
vip = (RadioButton)findViewById(R.id.radiovip);
cetak = (Button)findViewById(R.id.cetak);
@Override
public void onClick(View klik) {
// TODO Auto-generated method stub
nama.setText( +nama.getText());
banyak.setText(+banyak.getText());
jurusan.setChecked(false);
class .setChecked(false);
total.setText(+total.getText());
}
@Override
public void onCheckedChanged(RadioGroup, int check) {
// TODO Auto-generated method stub
if(check==R.id.radiosolo){
="Solo";
}else if(check==R.id.radiojogja){
="jogja";
}else(check==R.id.radiowonogiri){
="wonogiri";
}
@Override
public void onCheckedChanged(RadioGroup2, int check) {
// TODO Auto-generated method stub
if(check==R.id.radioexe){
="Executive";
}else(check==R.id.radiovip){
="VIP";
}
}
}
hasilnya setelag di run ..
Sekian Terima Kasih...
Komentar
Posting Komentar