Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.android.ale.llaundry;
- import android.content.Intent;
- import android.support.v7.app.AppCompatActivity;
- import android.os.Bundle;
- import android.view.Menu;
- import android.view.MenuItem;
- import android.view.View;
- import android.widget.Button;
- import android.widget.EditText;
- import android.widget.RadioGroup;
- import android.widget.TextView;
- import android.widget.Toast;
- public class MainActivity extends AppCompatActivity {
- EditText nama, alamat, telepon;
- Button order;
- RadioGroup paket;
- @Override
- public boolean onCreateOptionsMenu (Menu menu){
- getMenuInflater().inflate(R.menu.menu, menu);
- return true;
- }
- @Override
- public boolean onOptionsItemSelected(MenuItem item){
- switch (item.getItemId()){
- case R.id.action_contact:
- Intent intent_show = new Intent(MainActivity.this, ContactUs.class);
- intent_show.putExtra(Intent.EXTRA_TEXT,"Contact Us");
- startActivity(intent_show);
- //ke halaman tampilan semula
- return true;
- case R.id.action_home:
- Intent intent_delete = new Intent(MainActivity.this, MainActivity.class);
- intent_delete.putExtra(Intent.EXTRA_TEXT, "Data dari halaman main");
- startActivity(intent_delete);
- return true;
- }
- return super.onOptionsItemSelected(item);
- }
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_main);
- nama = (EditText) findViewById(R.id.edit_nama);
- alamat = (EditText) findViewById(R.id.edit_alamat);
- telepon = (EditText) findViewById(R.id.edit_telepon);
- order = (Button) findViewById(R.id.button_order);
- paket = (RadioGroup) findViewById(R.id.group_paket);
- order.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- if (nama.getText().toString().length() == 0) {
- nama.setError("Nama tidak boleh kosong!");
- } else if (nama.getText().toString().length() > 20) {
- nama.setError("Nama Tidak Boleh lebih dari 20 Karakter");
- } else if (alamat.getText().toString().length() == 0) {
- alamat.setError("Alamat tidak boleh kosong!");
- } else if (alamat.getText().toString().length() > 20) {
- alamat.setError("Alamat Tidak Boleh lebih dari 20 Karakter");
- } else if (telepon.getText().toString().length() == 0) {
- telepon.setError("Telepon tidak boleh kosong!");
- } else {
- Toast.makeText(getApplicationContext(), "Order Berhasil! Silahkan tunggu kurir kami mengambil cucian",
- Toast.LENGTH_SHORT).show();
- String order = "Nama : " + nama + "\n";
- order = order + "Alamat : " + alamat + "\n";
- order = order + "Paket : " + paket + "\n";
- order = order + "Telepon : " + telepon + "\n";
- }
- }
- });
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement