.LOGIN
Source Code Mainactivity.Java
package com.example.tetukodwicahyo_161011400118;
import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.EditText;
public class MainActivity extends Activity implements OnClickListener{
private String[][] dataUser = {{"ADMIN","ADMIN","Administrator"},
{"user1","password1","Nama User 1"},
{"user2","password2","Nama User 2"}};
private EditText userNameET, passwordET;
private final int SUCCESS=1;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
userNameET = (EditText) findViewById(R.id.userNameEditText);
passwordET = (EditText) findViewById(R.id.passwordEditText);
findViewById(R.id.loginButton).setOnClickListener(this);
findViewById(R.id.tutupButton).setOnClickListener(this);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
public void onClick(View v) {
// TODO Auto-generated method stub
switch (v.getId()){
case R.id.loginButton:
int i=0;
boolean success=false;
while ((i<dataUser.length) && (!success)){
if
((userNameET.getText().toString().equals(dataUser[i][0])) &&
(passwordET.getText().toString().equals(dataUser[i][1]))){
success=true;
} else {
i++;
}
}
Intent intent;
if (success){
intent = new Intent(this, MenuActivity.class);
intent.putExtra("namaUser", dataUser[i][2]);
startActivityForResult(intent,SUCCESS);
} else {
intent = new Intent(this, FailedActivity.class);
startActivity(intent);
}
startActivity(intent);
break;
case R.id.tutupButton:
System.exit(0);
}
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data){
switch (requestCode) {
case SUCCESS:
userNameET.setText("");
passwordET.setText("");
break;
}
}
}
.LOGIN
Source Code Activity main.xml
<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" >
<LinearLayout
android:id="@+id/linearLayout1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true" >
<TextView
android:id="@+id/textView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="Form Login"
android:textAppearance="?android:attr/textAppearanceMedium"
/>
</LinearLayout>
<LinearLayout
android:id="@+id/linearLayout2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_below="@+id/linearLayout1"
android:orientation="vertical" >
<TextView
android:id="@+id/textView2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="User Name" />
<EditText
android:id="@+id/userNameEditText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="User Name" >
<requestFocus />
</EditText>
</LinearLayout>
<LinearLayout
android:id="@+id/linearLayout3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_below="@+id/linearLayout2"
android:orientation="vertical" >
<TextView
android:id="@+id/textView3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Password" />
<EditText
android:id="@+id/passwordEditText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Password"
android:inputType="textPassword" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_below="@+id/linearLayout3" >
<Button
android:id="@+id/loginButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="3"
android:text="Login" />
<Button
android:id="@+id/tutupButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Tutup" />
</LinearLayout>
</RelativeLayout>
(Menu)Source Code Activity main.xml
<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"
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.lutfi.materiactivity.MenuActivity" >
<LinearLayout
android:id="@+id/linearLayout1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginLeft="18dp" >
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="18dp"
android:text="BERANDA"
android:textAppearance="?android:attr/textAppearanceLarge" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/linearLayout1"
android:layout_centerHorizontal="true"
android:orientation="vertical" >
<Button
android:id="@+id/button1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="1. PENDAFTARAN WARGA" />
<Button
android:id="@+id/button2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="2. Data Warga" />
<Button
android:id="@+id/button4"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="3. KOMENTAR NETIJEN" />
<Button
android:id="@+id/button3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="4. LOUGOUT" />
</LinearLayout>
</RelativeLayout>
(Menu)Source Code Mainactivity.Java
package com.example.tetukodwicahyo_161011400118;
importandroid.os.Bundle;
importandroid.app.Activity;
importandroid.content.Intent;
importandroid.view.Menu;
importandroid.view.MenuItem;
importandroid.view.View;
importandroid.widget.Button;
import android.support.v4.app.NavUtils;
publicclassMenuActivityextends Activity {
Button btnPendaftaranWarga;
Button btnLihatWarga;
Button btnLogout;
@Override
publicvoidonCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_menu);
//getActionBar().setDisplayHomeAsUpEnabled(true);
btnPendaftaranWarga = (Button) findViewById(R.id.btnPendaftaranWarga);
btnLihatWarga = (Button) findViewById(R.id.btnLihatWarga);
btnLogout = (Button) findViewById(R.id.btnLogout);
btnPendaftaranWarga.setOnClickListener(newView.OnClickListener()
{
publicvoidonClick(View v) {
// TODO Auto-generated method stub
Intent i = newIntent(MenuActivity.this, PendaftaranActivity.class);
i.putExtra("Pesan", "Form PendaftaranWarga");
startActivity(i);
}
}
btnLogout.setOnClickListener(newView.OnClickListener() {
publicvoidonClick(View v) {
// TODO Auto-generated method stub
moveTaskToBack(true);
android.os.Process.killProcess(android.os.Process.myPid());
System.exit(0);
}
}
}
@Override
publicbooleanonCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.activity_menu, menu);
returntrue;
}
@Override
publicbooleanonOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
caseandroid.R.id.home:
NavUtils.navigateUpFromSameTask(this);
returntrue;
}
returnsuper.onOptionsItemSelected(item);
}
}
(PENDAFTARAN)Source Code Mainactivity.Java
packagecom.anggi.aplikasirtonline;
importandroid.os.Bundle;
importandroid.app.Activity;
importandroid.view.Menu;
importandroid.view.MenuItem;
import android.support.v4.app.NavUtils;
public class PendaftaranActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_pendaftaran);
getActionBar().setDisplayHomeAsUpEnabled(true);
}
@Override
publicbooleanonCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.activity_pendaftaran, menu);
return true;
}
@Override
publicbooleanonOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
caseandroid.R.id.home:
NavUtils.navigateUpFromSameTask(this);
return true;
}
returnsuper.onOptionsItemSelected(item);
}
}
(PENDAFTARAN)Source Code Activity main.xml
<RelativeLayoutxmlns: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:scrollbarStyle="insideOverlay"
android:scrollbars="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:scrollbars="vertical">
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Data KepalaKeluarga"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textStyle="bold"/>
<TextView
android:id="@+id/textView11"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=" "
android:textAppearance="?android:attr/textAppearanceSmall"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="NIK :"/>
<EditText
android:id="@+id/etxtKKNIK"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="10"
android:inputType="number"/>
<requestFocus/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="NamaLengkap :"/>
<EditText
android:id="@+id/etxtKKNamaLengkap"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="10">
</EditText>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/textView5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="NamaPanggilan :"/>
<EditText
android:id="@+id/etxtKKNamaPanggilan"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="10"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="JenisKelamin :"/>
<RadioButton
android:id="@+id/rbtnKKJKPria"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Pria"/>
<RadioButton
android:id="@+id/rbtnKKJKWanita"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Wanita"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/textView6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Kota Kelahiran :"/>
<EditText
android:id="@+id/etxtKKKotaKelahiran"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="10"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/textView7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TanggalLahir :"/>
<EditText
android:id="@+id/etxtKKTanggalLahir"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="10"
android:inputType="date"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/textView8"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="e-mail :"/>
<EditText
android:id="@+id/etxtKKEmail"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="10"
android:inputType="textEmailAddress"/>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:id="@+id/textView9"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Pekerjaan :"/>
<EditText
android:id="@+id/etxtKKPekerjaan"
android:layout_width="245dp"
android:layout_height="wrap_content"
android:ems="10"/>
</LinearLayout>
<TextView
android:id="@+id/textView10"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=" "
android:textAppearance="?android:attr/textAppearanceMedium"/>
<Button
android:id="@+id/btnKKSelanjutnya"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Selanjutnya"/>
</LinearLayout>
Tidak ada komentar:
Posting Komentar