UTS MOBILE PROGRAMING
1. Deskripsi
Reservasi
Kali ini saya mencoba membuat aplikasi sederhana penjualan baju menggunakan Radio Button Eckipse Android
2. XML Text
A. XML Login
<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/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="20dp"
android:text="DEDI STORE"
android:textSize="30sp"
android:textStyle="bold|italic" />
<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_marginLeft="37dp"
android:layout_marginTop="25dp"
android:text="User Name"
android:textSize="20sp" />
<EditText
android:id="@+id/userid"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/textView2"
android:layout_below="@+id/textView2"
android:ems="10" />
<EditText
android:id="@+id/passid"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/textView3"
android:layout_centerVertical="true"
android:ems="10" >
<requestFocus />
</EditText>
<Button
android:id="@+id/btlogin"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignRight="@+id/textView2"
android:layout_below="@+id/passid"
android:layout_marginTop="20dp"
android:text="Login" />
<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@+id/passid"
android:layout_alignLeft="@+id/userid"
android:layout_marginBottom="16dp"
android:text="Password"
android:textSize="20sp" />
<Button
android:id="@+id/btclose"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/btlogin"
android:layout_alignBottom="@+id/btlogin"
android:layout_alignRight="@+id/textView1"
android:layout_marginRight="16dp"
android:text="Close" />
</RelativeLayout>
B. XML penjualan baju
<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=".SuccessActivity" >
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="32dp"
android:text="FASHION DEDI DIANA STOTRE"
android:textSize="20sp" />
<EditText
android:id="@+id/idbeli"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/textView2"
android:layout_alignBottom="@+id/textView2"
android:layout_alignParentRight="true"
android:layout_toRightOf="@+id/textView2"
android:ems="10" />
<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="52dp"
android:text="No. Pembelian"
android:textSize="20sp" />
<RadioGroup
android:id="@+id/radioGroup1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/idbeli"
android:layout_marginTop="20dp"
android:layout_toRightOf="@+id/textView2" >
<RadioButton
android:id="@+id/bajuRB"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="true"
android:text="Baju Lengan Panjang" />
<RadioButton
android:id="@+id/kemejaRB"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Kemeja" />
<RadioButton
android:id="@+id/batikRB"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Batik" />
</RadioGroup>
<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/textView1"
android:layout_below="@+id/radioGroup1"
android:layout_marginTop="39dp"
android:text="Harga" />
<EditText
android:id="@+id/idharga"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/textView3"
android:layout_alignBottom="@+id/textView3"
android:layout_alignLeft="@+id/radioGroup1"
android:layout_marginLeft="14dp"
android:ems="10" >
<requestFocus />
</EditText>
<EditText
android:id="@+id/idjumlah"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/textView4"
android:layout_alignBottom="@+id/textView4"
android:layout_alignLeft="@+id/idharga"
android:ems="10" />
<EditText
android:id="@+id/idtotal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/textView5"
android:layout_alignBottom="@+id/textView5"
android:layout_alignLeft="@+id/idjumlah"
android:ems="10" />
<TextView
android:id="@+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/textView3"
android:layout_below="@+id/idharga"
android:layout_marginTop="14dp"
android:text="Jumlah" />
<TextView
android:id="@+id/textView5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/textView4"
android:layout_below="@+id/idjumlah"
android:layout_marginTop="14dp"
android:text="Total" />
<Button
android:id="@+id/hitungRB"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginBottom="16dp"
android:layout_toRightOf="@+id/textView2"
android:text="Hitung"
android:textSize="15sp" />
</RelativeLayout>
3.XML Graphic
A.Design Login
B. Design Penjualan
4. Source Coding (Java)
B. Hasil Run Penjualan
Terimakasih......
WASSALAAAAMMMMM....!!!!!
Reservasi
Kali ini saya mencoba membuat aplikasi sederhana penjualan baju menggunakan Radio Button Eckipse Android
2. XML Text
A. XML Login
<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/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="20dp"
android:text="DEDI STORE"
android:textSize="30sp"
android:textStyle="bold|italic" />
<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_marginLeft="37dp"
android:layout_marginTop="25dp"
android:text="User Name"
android:textSize="20sp" />
<EditText
android:id="@+id/userid"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/textView2"
android:layout_below="@+id/textView2"
android:ems="10" />
<EditText
android:id="@+id/passid"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/textView3"
android:layout_centerVertical="true"
android:ems="10" >
<requestFocus />
</EditText>
<Button
android:id="@+id/btlogin"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignRight="@+id/textView2"
android:layout_below="@+id/passid"
android:layout_marginTop="20dp"
android:text="Login" />
<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@+id/passid"
android:layout_alignLeft="@+id/userid"
android:layout_marginBottom="16dp"
android:text="Password"
android:textSize="20sp" />
<Button
android:id="@+id/btclose"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/btlogin"
android:layout_alignBottom="@+id/btlogin"
android:layout_alignRight="@+id/textView1"
android:layout_marginRight="16dp"
android:text="Close" />
</RelativeLayout>
B. XML penjualan baju
<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=".SuccessActivity" >
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="32dp"
android:text="FASHION DEDI DIANA STOTRE"
android:textSize="20sp" />
<EditText
android:id="@+id/idbeli"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/textView2"
android:layout_alignBottom="@+id/textView2"
android:layout_alignParentRight="true"
android:layout_toRightOf="@+id/textView2"
android:ems="10" />
<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="52dp"
android:text="No. Pembelian"
android:textSize="20sp" />
<RadioGroup
android:id="@+id/radioGroup1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/idbeli"
android:layout_marginTop="20dp"
android:layout_toRightOf="@+id/textView2" >
<RadioButton
android:id="@+id/bajuRB"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="true"
android:text="Baju Lengan Panjang" />
<RadioButton
android:id="@+id/kemejaRB"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Kemeja" />
<RadioButton
android:id="@+id/batikRB"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Batik" />
</RadioGroup>
<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/textView1"
android:layout_below="@+id/radioGroup1"
android:layout_marginTop="39dp"
android:text="Harga" />
<EditText
android:id="@+id/idharga"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/textView3"
android:layout_alignBottom="@+id/textView3"
android:layout_alignLeft="@+id/radioGroup1"
android:layout_marginLeft="14dp"
android:ems="10" >
<requestFocus />
</EditText>
<EditText
android:id="@+id/idjumlah"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/textView4"
android:layout_alignBottom="@+id/textView4"
android:layout_alignLeft="@+id/idharga"
android:ems="10" />
<EditText
android:id="@+id/idtotal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/textView5"
android:layout_alignBottom="@+id/textView5"
android:layout_alignLeft="@+id/idjumlah"
android:ems="10" />
<TextView
android:id="@+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/textView3"
android:layout_below="@+id/idharga"
android:layout_marginTop="14dp"
android:text="Jumlah" />
<TextView
android:id="@+id/textView5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/textView4"
android:layout_below="@+id/idjumlah"
android:layout_marginTop="14dp"
android:text="Total" />
<Button
android:id="@+id/hitungRB"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginBottom="16dp"
android:layout_toRightOf="@+id/textView2"
android:text="Hitung"
android:textSize="15sp" />
</RelativeLayout>
3.XML Graphic
A.Design Login
B. Design Penjualan
4. Source Coding (Java)
package com.example.dedidiana;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.Toast;
public class SuccessActivity extends Activity {
RadioButton baju;
RadioButton kemeja;
RadioButton batik;
RadioGroup pakaian;
Button hitung;
EditText harga;
EditText jumlah;
EditText total;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_success);
baju =(RadioButton) findViewById(R.id.bajuRB);
kemeja =(RadioButton) findViewById(R.id.kemejaRB);
batik =(RadioButton) findViewById(R.id.batikRB);
pakaian =(RadioGroup) findViewById(R.id.radioGroup1);
harga =(EditText) findViewById(R.id.idharga);
jumlah =(EditText) findViewById(R.id.idjumlah);
total =(EditText) findViewById(R.id.idtotal);
hitung = (Button) findViewById(R.id.hitungRB);
hitung.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
int h=Integer.parseInt(jumlah.getText().toString());
int j=Integer.parseInt(harga.getText().toString());
int totall=h*j;
total.setText(""+totall);
}
});
}
public void onCheckedChanged(RadioGroup arg0, int CheckId) {
// TODO Auto-generated method stub
if(baju.isChecked()){
Toast.makeText(this, "Baju Lengan Panjang", Toast.LENGTH_SHORT).show();
harga.setText("62300");
}else if (kemeja.isChecked()){
Toast.makeText(this, "Kemeja Bunga-Bunga", Toast.LENGTH_SHORT).show();
harga.setText("85900");
}else{
Toast.makeText(this, "JumpSuite", Toast.LENGTH_SHORT).show();
harga.setText("78500");
}
}
@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_success, menu);
return true;
}
}
5.Screen Shoot Run Pada Emulator. Gadget Android
A. Login
B. Hasil Run Penjualan
Terimakasih......
WASSALAAAAMMMMM....!!!!!
Komentar
Posting Komentar