- XML Grafic
- xml text form login
<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" >
<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: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>
- List Menu Grafik
package com.example.Muhammad_anwar;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.app.Activity;
import android.content.Intent;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.Toast;
public class MenuActivity extends Activity {
ListView LV;
String[] Menu={"Garuda", "Batik Air","Lion Air", "City Link", "Sriwijaya"};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_menu);
LV=(ListView) findViewById(R.id.listView1);
ArrayAdapter Adapter=new ArrayAdapter(this,android.R.layout.simple_list_item_single_choice,Menu);
LV.setAdapter(Adapter);
//MEMBUAT ITEM VIEW KLIK PADA LISTVIEW dan MEMBUAT PESAN (TOAST
LV.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> arg0, View arg1, int itemKe,
long arg3) {
//TODO Auto-generated method stub
String itemText=(String) LV.getItemAtPosition(itemKe);
Toast.makeText(getBaseContext(), "Anda Meng Klik " +itemText, Toast.LENGTH_LONG).show();
if(itemText.equals("Tiket Pesawat")){
Intent FinanceInten=new Intent(arg0.getContext(),IsiActivity.class);
startActivityForResult(FinanceInten, 0);
}
}
public void onItemClick1(AdapterView<?> arg0, View arg1, int arg2,
long arg3) {
// TODO Auto-generated method stub
}
});
}
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.activity_menu, menu);
return true;
}
}
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.app.Activity;
import android.content.Intent;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.Toast;
public class MenuActivity extends Activity {
ListView LV;
String[] Menu={"Garuda", "Batik Air","Lion Air", "City Link", "Sriwijaya"};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_menu);
LV=(ListView) findViewById(R.id.listView1);
ArrayAdapter Adapter=new ArrayAdapter(this,android.R.layout.simple_list_item_single_choice,Menu);
LV.setAdapter(Adapter);
//MEMBUAT ITEM VIEW KLIK PADA LISTVIEW dan MEMBUAT PESAN (TOAST
LV.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> arg0, View arg1, int itemKe,
long arg3) {
//TODO Auto-generated method stub
String itemText=(String) LV.getItemAtPosition(itemKe);
Toast.makeText(getBaseContext(), "Anda Meng Klik " +itemText, Toast.LENGTH_LONG).show();
if(itemText.equals("Tiket Pesawat")){
Intent FinanceInten=new Intent(arg0.getContext(),IsiActivity.class);
startActivityForResult(FinanceInten, 0);
}
}
public void onItemClick1(AdapterView<?> arg0, View arg1, int arg2,
long arg3) {
// TODO Auto-generated method stub
}
});
}
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.activity_menu, menu);
return true;
}
}
- isi menu dari activity
- xml menu dari isi activity
package com.example.Muhammad_anwar;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.TextView;
import android.widget.RadioGroup.OnCheckedChangeListener;
public class IsiActivity extends Activity implements OnClickListener,
OnCheckedChangeListener {
EditText fieldnama,fieldemail;
Button tomboltampil;
RadioGroup groupjk;
RadioButton radiomi, radiodendeng;
CheckBox cekboxjava, cekboxsa, cekboxnet;
TextView outputnama, outputemail, outputjk, outputahli;
String jk, ahli;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_isi);
fieldemail = (EditText)findViewById(R.id.fieldemail);
fieldnama = (EditText)findViewById(R.id.fieldnama);
tomboltampil = (Button)findViewById(R.id.tomboltampil);
groupjk = (RadioGroup)findViewById(R.id.groupjk);
cekboxjava = (CheckBox)findViewById(R.id.cekboxjava);
cekboxsa = (CheckBox)findViewById(R.id.cekboxsa);
cekboxnet = (CheckBox)findViewById(R.id.cekboxnet);
outputnama =(TextView)findViewById(R.id.outputnama);
outputemail =(TextView)findViewById(R.id.outputemail);
outputahli = (TextView)findViewById(R.id.outputahli);
outputjk = (TextView)findViewById(R.id.outputjk);
tomboltampil.setOnClickListener(this);
groupjk.setOnCheckedChangeListener(this);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.activity_isi, menu);
return true;
}
public void onClick(View klik) {
// TODO Auto-generated method stub
outputnama.setText("Nama Anda : "+fieldnama.getText());
outputemail.setText("No Telp : "+fieldemail.getText());
if (cekboxjava.isChecked() && cekboxnet.isChecked() && cekboxsa.isChecked()){
outputahli.setText("Class : VIP, Ekonomi");
}else if(cekboxjava.isChecked() && cekboxnet.isChecked()){
outputahli.setText("Class : VIP & Ekonomi");
}else if(cekboxjava.isChecked() && cekboxsa.isChecked()){
outputahli.setText("Class : VIPk & Ekonomi");
}else if(cekboxnet.isChecked() && cekboxsa.isChecked()){
outputahli.setText("Class : VIP & Ekonomi");
}else if(cekboxjava.isChecked()){
outputahli.setText("Class : VIP");
}else if(cekboxnet.isChecked()){
outputahli.setText("Class : Ekonomi");
}else if(cekboxsa.isChecked()){
outputahli.setText("Class : loss");
}else{
outputahli.setText("Class : ");
}
outputjk.setText(jk);
fieldnama.setText("");
fieldemail.setText("");
cekboxjava.setChecked(false);
cekboxsa.setChecked(false);
cekboxnet.setChecked(false);
groupjk.clearCheck();
}
jk="Jenis Kelamin :";
}
}
}
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.TextView;
import android.widget.RadioGroup.OnCheckedChangeListener;
public class IsiActivity extends Activity implements OnClickListener,
OnCheckedChangeListener {
EditText fieldnama,fieldemail;
Button tomboltampil;
RadioGroup groupjk;
RadioButton radiomi, radiodendeng;
CheckBox cekboxjava, cekboxsa, cekboxnet;
TextView outputnama, outputemail, outputjk, outputahli;
String jk, ahli;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_isi);
fieldemail = (EditText)findViewById(R.id.fieldemail);
fieldnama = (EditText)findViewById(R.id.fieldnama);
tomboltampil = (Button)findViewById(R.id.tomboltampil);
groupjk = (RadioGroup)findViewById(R.id.groupjk);
cekboxjava = (CheckBox)findViewById(R.id.cekboxjava);
cekboxsa = (CheckBox)findViewById(R.id.cekboxsa);
cekboxnet = (CheckBox)findViewById(R.id.cekboxnet);
outputnama =(TextView)findViewById(R.id.outputnama);
outputemail =(TextView)findViewById(R.id.outputemail);
outputahli = (TextView)findViewById(R.id.outputahli);
outputjk = (TextView)findViewById(R.id.outputjk);
tomboltampil.setOnClickListener(this);
groupjk.setOnCheckedChangeListener(this);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.activity_isi, menu);
return true;
}
public void onClick(View klik) {
// TODO Auto-generated method stub
outputnama.setText("Nama Anda : "+fieldnama.getText());
outputemail.setText("No Telp : "+fieldemail.getText());
if (cekboxjava.isChecked() && cekboxnet.isChecked() && cekboxsa.isChecked()){
outputahli.setText("Class : VIP, Ekonomi");
}else if(cekboxjava.isChecked() && cekboxnet.isChecked()){
outputahli.setText("Class : VIP & Ekonomi");
}else if(cekboxjava.isChecked() && cekboxsa.isChecked()){
outputahli.setText("Class : VIPk & Ekonomi");
}else if(cekboxnet.isChecked() && cekboxsa.isChecked()){
outputahli.setText("Class : VIP & Ekonomi");
}else if(cekboxjava.isChecked()){
outputahli.setText("Class : VIP");
}else if(cekboxnet.isChecked()){
outputahli.setText("Class : Ekonomi");
}else if(cekboxsa.isChecked()){
outputahli.setText("Class : loss");
}else{
outputahli.setText("Class : ");
}
outputjk.setText(jk);
fieldnama.setText("");
fieldemail.setText("");
cekboxjava.setChecked(false);
cekboxsa.setChecked(false);
cekboxnet.setChecked(false);
groupjk.clearCheck();
}
jk="Jenis Kelamin :";
}
}
}