FORM LOGIN
package com.example.sewabaju
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;
import android.widget.Toast;
public class MainActivity extends Activity {
private
EditText username;
private
EditText pass;
@Override
protected
void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
username=
(EditText) findViewById(R.id.Txtuser);
pass=
(EditText) findViewById(R.id.Txtpassword);
Button
login = (Button)findViewById(R.id.login);
}
public
void Login(View view){
String
Nm = username.getText().toString();
String
psw = pass.getText().toString();
if
(Nm.equals("admin") && psw.equals("1")){
Intent
i = new Intent (this,MenuActivity.class);
startActivityForResult(i,
0);
}
else
{
Toast.makeText(getApplicationContext(),
"Password
Atau Username Salah, Silahkan Coba Lagi",
Toast.LENGTH_LONG).show();
}
}
}
FORM MENU
Saat pilihan menu hanya menambah kan onclik
<Button
android:id="@+id/pria"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="20dp"
android:layout_marginTop="32dp"
android:text="Pria"
android:onClick="Pria"/>
<Button
android:id="@+id/wanita"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/pria"
android:layout_alignBottom="@+id/pria"
android:layout_marginLeft="41dp"
android:layout_toRightOf="@+id/pria"
android:text="Wanita"
android:onClick="Wanita" />
CARI TOTAL HARGA SEWA BAJU
package
com.example.sewabaju;
import
android.os.Bundle;
import
android.app.Activity;
import android.app.AlertDialog;
import
android.content.DialogInterface;
import
android.view.Menu;
import
android.view.View;
import
android.widget.Button;
import
android.widget.EditText;
import android.widget.LinearLayout;
import
android.widget.RadioButton;
import
android.widget.RadioGroup;
import
android.widget.Toast;
import
android.widget.RadioGroup.OnCheckedChangeListener;
public class PriaActivity extends Activity implements
android.widget.RadioGroup.OnCheckedChangeListener{
RadioButton
RB0,RB1;
public static final String EXTRA_TEXT="com.example.EXTRA_TEXT";
public static final String EXTRA_NUMBER="com.example.EXTRA_NUMBER";
EditText editText1,editText2,editText3,editText4;
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_pria);
RB0 = (RadioButton)findViewById(R.id.radio0);
RB1 = (RadioButton)findViewById(R.id.radio1);
radioGroup=(RadioGroup)findViewById(R.id.radioGroup1);
radioGroup.setOnCheckedChangeListener((OnCheckedChangeListener)
this);
editText1=(EditText)findViewById(R.id.editText1);
editText2=(EditText)findViewById(R.id.editText2);
editText3=(EditText)findViewById(R.id editText3.);
editText4=(EditText)findViewById(R.id.editText4);
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(editText1.getText().toString());
int j=Integer.parseInt(editText2.getText().toString());
int total =h*j;
editText4.setText(""+total);
String
alert1="anda memilih paket snack dengan isi "+editText3.getText();
String
alert2="sebanyak "+editText2.getText()+"
pcs";
String
alert3="dengan harga/pcs "+editText1.getText();
String
alert4="grand total "+editText4.getText();
String
alert5="pesanan akan segera sampai di alamat anda";
String
alert6="TERIMAKASIH";
AlertDialog.Builder
builder = new AlertDialog.Builder(PriaActivity.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.menu, menu);
return true;
}
@Override
public void
onCheckedChanged(RadioGroup arg0, int arg1) {
if(RB0.isChecked()){
Toast.makeText(this,"Snack
original best of the best",Toast.LENGTH_LONG).show();
editText3.setText("french
fries");
editText1.setText("12000");
}else if(RB1.isChecked()) {
Toast.makeText(this,"crispy
chicken wings,tasteful",Toast.LENGTH_LONG).show();
editText3.setText("chicken
wings");
editText1.setText("7000");
}
}
}
Sampai sini harusnya bisa di run tapi karna kendala
laptop lemot dan kurang mendukung jadi ga bisa menampilkan hasil run