Assalamualaikum wr.wb
Di kesempatan kali ini saya akan membuat sebuah aplikasi untuk memenuhi nilai uas saya dalam mata kuliah mobile programming
Deskripsinya disini saya akan memmbuat aplikasi penyewaan koper nanti ada pilihan untuk jenis dan setiap koper ada keistimewaannya masing masing dan setiap koper memiliki harga yg beda beda,ada yg besar sampai yg kecil,yg besar sendiri memiliki bonus tersendiri dan yg sedang juga ada kelebihan tersendiri tetapi tidak seistimewa yg besa dan ada yg kecil,nah yg kecil ini dia tidak memiliki bonus atau keistimewaannya makanya harganya murah.Langsung saja ini dia screenshotannya dibawah
Adapun sebelum kita memilih pesanan terlebih dahulu harus login seperti screenshoot di bawah ini
Adapun codingannya seperti dibawah ini
package com.example.uas;
import android.os.Bundle;
import android.app.Activity;
import android.app.AlertDialog;
import android.view.*;
import android.widget.Button;
import android.widget.EditText;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.Toast;
import android.widget.RadioGroup.OnCheckedChangeListener;
import android.view.View;
import android.content.Intent;
import android.content.*;
import android.app.*;
import android.app.AlertDialog.Builder;
import android.widget.*;
public class Tab_snack extends Activity implements android.widget.RadioGroup.OnCheckedChangeListener{
RadioButton rb0,rb1,rb2;
public static final String EXTRA_TEXT="com.example.EXTRA_TEXT";
public static final String EXTRA_NUMBER="com.example.EXTRA_NUMBER";
EditText edit1,edit2,edit3,edit4;
Button pesan;
RadioGroup radioGroup;
String tujuan,varktp,varnama,vartlp;
Integer harga, total, jumlah;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_tab_koper;
rb0 = (RadioButton)findViewById(R.id.nike);
rb1 = (RadioButton)findViewById(R.id.adidas);
rb2 = (RadioButton)findViewById(R.id.biasa);
radioGroup=(RadioGroup)findViewById(R.id.radioGroup1);
radioGroup.setOnCheckedChangeListener((OnCheckedChangeListener) this);
edit1=(EditText)findViewById(R.id.textharga);
edit2=(EditText)findViewById(R.id.textquantity);
edit3=(EditText)findViewById(R.id.textisi);
edit4=(EditText)findViewById(R.id.texttotal);
pesan= (Button) findViewById(R.id.button1);
pesan.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
int h=Integer.parseInt(edit1.getText().toString());
int j=Integer.parseInt(edit2.getText().toString());
int total =h*j;
edit4.setText(""+total);
String alert1="anda memilih paket koper dengan isi "+edit3.getText();
String alert2="sebanyak "+edit2.getText()+" pcs";
String alert3="dengan harga/pcs "+edit1.getText();
String alert4="grand total "+edit4.getText();
String alert5="pesanan akan segera sampai di alamat anda";
String alert6="TERIMAKASIH";
AlertDialog.Builder builder = new AlertDialog.Builder(Tab_snack.this);
builder.setTitle("pembelian berhasil !!").setMessage
(alert1+ "\n" +alert2+ "\n" +alert3+"\n"+alert4+ "\n" +alert5+ "\n" +alert6).setNeutralButton("close", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int witch) {
// TODO Auto-generated method stub
dialog.cancel();
}
}).show();
}
});
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.tab_koper, menu);
return true;
}
@Override
public void onCheckedChanged(RadioGroup arg0, int arg1) {
if(rb0.isChecked()){
Toast.makeText(this,"Besar",Toast.LENGTH_LONG).show();
edit3.setText("bonus koper tambahan");
edit1.setText("3.000.000");
}else if(rb1.isChecked()) {
Toast.makeText(this,"Sedang",Toast.LENGTH_LONG).show();
edit3.setText("bonus minum");
edit1.setText("2.000.000");
}else if(rb2.isChecked()) {
Toast.makeText(this,"Kecil",Toast.LENGTH_LONG).show();
edit3.setText("gada bonus");
edit1.setText("1.500.0000");
}
}
}
package com.example.uas;
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 UTS extends Activity {
EditText name;
EditText password;
Button btnlogin;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_uts);
name=(EditText)findViewById(R.id.fname);
password=(EditText)findViewById(R.id.fpass);
btnlogin=(Button)findViewById(R.id.btnlogin);
btnlogin.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
validate(name.getText().toString(),password.getText().toString());
}
});
}
private void validate(String username, String pwd){
if ((username.equals("Prahasto Hidayatullah"))&&(pwd.equals("1234567"))){
Intent intent= new Intent(UTS.this, Utama.class);
startActivity(intent);
}
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.uas, menu);
return true;
}
}
Sekian mungkin cuma ini aja semoga bermanfaat
Wassalamualaikum wr.b