Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 15

Form

Oleh :
Moh. Syahrul Ramadhan (361555401097)

Teknik Informatika
Politeknik Negeri Banyuwangi
2017
 Source code “Login.java”
package com.a361555401097.form;

import android.content.Intent;

import android.support.v7.app.AppCompatActivity;

import android.os.Bundle;

import android.view.View;

import android.widget.Button;

public class Login extends AppCompatActivity {

private Button login, daftar;

@Override

protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.activity_login);

//kita ambil ID yang Button

login = (Button) findViewById(R.id.login);

daftar = (Button) findViewById(R.id.sign_up_button);

login.setOnClickListener(new View.OnClickListener() {

@Override

public void onClick(View v) {

Intent intent = new Intent(Login.this, tampil.class);


Login.this.startActivity(intent);

Login.this.finish();

});

daftar.setOnClickListener(new View.OnClickListener() {

@Override

public void onClick(View v) {

Intent intent = new Intent(Login.this, daftar.class);

Login.this.startActivity(intent);

Login.this.finish();

});

 Source code file “Activity_login”


<LinearLayout 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"

android:gravity="center_horizontal"

android:orientation="vertical"

android:paddingBottom="@dimen/activity_vertical_margin"

android:paddingLeft="@dimen/activity_horizontal_margin"

android:paddingRight="@dimen/activity_horizontal_margin"

android:paddingTop="@dimen/activity_vertical_margin"

tools:context="com.a361555401097.form.Login">
<!-- Login progress -->

<ProgressBar

android:id="@+id/login_progress"

style="?android:attr/progressBarStyleLarge"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_marginBottom="8dp"

android:visibility="gone" />

<ScrollView

android:id="@+id/login_form"

android:layout_width="match_parent"

android:layout_height="match_parent">

<LinearLayout

android:id="@+id/email_login_form"

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:orientation="vertical">

<android.support.design.widget.TextInputLayout

android:layout_width="match_parent"

android:layout_height="wrap_content">

<AutoCompleteTextView

android:id="@+id/username"

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:hint="@string/prompt_username"
android:inputType="textEmailAddress"

android:maxLines="1"

android:singleLine="true" />

</android.support.design.widget.TextInputLayout>

<android.support.design.widget.TextInputLayout

android:layout_width="match_parent"

android:layout_height="wrap_content">

<EditText

android:id="@+id/password"

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:hint="@string/prompt_password"

android:imeActionId="@+id/login"

android:imeActionLabel="@string/action_sign_in_short"

android:imeOptions="actionUnspecified"

android:inputType="textPassword"

android:maxLines="1"

android:singleLine="true" />

</android.support.design.widget.TextInputLayout>

<Button

android:id="@+id/login"

style="?android:textAppearanceSmall"

android:layout_width="match_parent"

android:layout_height="wrap_content"
android:layout_marginTop="16dp"

android:text="@string/action_login"

android:textStyle="bold" />

<TextView

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:id="@+id/textView4"

android:text="Belum memiliki akun, silahkan" />

<Button

android:id="@+id/sign_up_button"

style="?android:textAppearanceSmall"

android:layout_width="143dp"

android:layout_height="wrap_content"

android:layout_marginTop="16dp"

android:text="@string/action_sign_up"

android:textStyle="bold" />

</LinearLayout>

</ScrollView>

</LinearLayout>
Screenshot:

Analisa : pada file login terdapat field username dan password, dimana username bertipe “text”
sedangkan field password bertipe “password” dan juga terdapat button login yang mengarah pada file
“tampil.java” dan button sign up yang mengarah pada file “ daftar.java”. untuk mengarahkan file
menggunakan inten dengan format Intent intent = new Intent(Login.this, tampil.class); untuk
mengarahkan button login ke “file tampil.java” dan Intent intent = new Intent(Login.this, daftar.class);
untuk mengarahkan tombol sign up ke file “daftar.java”
 Source Code File Daftar.java
package com.a361555401097.form;

import android.support.v7.app.AppCompatActivity;

import android.os.Bundle;

public class daftar extends AppCompatActivity {

@Override

protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.activity_daftar);

Source Code File “Actifity_daftar.xml”

<?xml version="1.0" encoding="utf-8"?>

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"

android:orientation="vertical" android:layout_width="match_parent"

android:layout_height="match_parent">

<TextView

android:text="Nama Lengkap"

android:layout_width="match_parent"

android:layout_height="wrap_content"
android:id="@+id/nama" />

<EditText

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:inputType="textPersonName"

android:ems="10"

android:id="@+id/nama" />

<TextView

android:text="No.Handphone /Telepon"

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:id="@+id/telepon" />

<EditText

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:inputType="number"

android:ems="10"

android:id="@+id/telepon" />

<TextView

android:text="Toko / Usaha"

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:id="@+id/toko" />

<EditText
android:layout_width="match_parent"

android:layout_height="wrap_content"

android:inputType="textPersonName"

android:ems="10"

android:id="@+id/toko" />

<TextView

android:text="Email"

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:id="@+id/email" />

<EditText

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:inputType="textEmailAddress"

android:ems="10"

android:id="@+id/email" />

<TextView

android:text="Password"

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:id="@+id/password" />

<EditText

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:inputType="textPassword"
android:ems="10"

android:id="@+id/password" />

<TextView

android:text="Pilih Paket"

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:id="@+id/paket" />

<Spinner

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:id="@+id/spinner" />

</LinearLayout>

Screenshoot:
Analisa :
Di dalam file activity_daftar.xml terdapat field nama lengkap, no handphone, took, email,
password dan spinner pilih paket

 Source Code File “Tampil.java”


package com.a361555401097.form;

import android.content.Intent;

import android.support.v7.app.AppCompatActivity;

import android.os.Bundle;

import android.view.View;

import android.widget.Button;

public class tampil extends AppCompatActivity {

private Button logout;

@Override

protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.activity_tampil);

logout = (Button) findViewById(R.id.logout);

logout.setOnClickListener(new View.OnClickListener() {

@Override

public void onClick(View v) {

Intent intent = new Intent(tampil.this, Login.class);

tampil.this.startActivity(intent);
tampil.this.finish();

});

 Source Code File “Activity_tampil”


<?xml version="1.0" encoding="utf-8"?>

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"

android:orientation="vertical" android:layout_width="match_parent"

android:layout_height="match_parent">

<TextView

android:text="Halo, Selamat Datang"

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:id="@+id/textView" />

<Button

android:text="DASHBOARD"

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:id="@+id/button" />

<Button

android:text="ORDER"

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:id="@+id/button2" />
<Button

android:text="PRODUK"

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:id="@+id/button3" />

<Button

android:text="LAPORAN"

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:id="@+id/button4" />

<Button

android:text="SETTING"

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:id="@+id/button5" />

<Button

android:text="LOGOUT"

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:id="@+id/logout" />

</LinearLayout>
Screenshoot :

Analisa : didalam file activity_tampil.xml terdapat button DASHBOARD, ORDER, PRODUK,


LAPORAN, SETTING, LOGOUT, dimana pada button LOGOUT terdapat intent untuk mengarahkan file ke
Login.”java”

You might also like