haii gays assalamu allaikum.Wr.Wb semoga masih semngat ngoding ya gayss … hari ini saya ingin membuat tutorial pembuatan pesanan kopi dengan menggunakan eclipse .cara -caranya sebagai berikut:
1.pertama-tama kita buka aplikasi eclips -> klik file--> New projet -->Android Application Project kemudian beri nama project.
2.Buatan blank android activity dengan klik src --.com.example-->other --.android activity lalu nama sesuai design kalian inginkan
berikut condingannya:
package com.example.restajunior;
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.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;
public class LOGINActivity extends Activity {
EditText UserName;
EditText password;
Button login;
Button exit;
EditText UserName;
EditText password;
Button login;
Button exit;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login);
UserName = (EditText) findViewById(R.id.editText2);
password = (EditText) findViewById(R.id.editText3);
login = (Button) findViewById(R.id.button1);
exit = (Button) findViewById(R.id.button2);
login.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Intent i = new Intent(LOGINActivity.this,MENUActivity.class);
i.putExtra("pesan","sukses login");
startActivity(i);
}
});
}
@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_login, menu);
return true;
}
}
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.activity_login, menu);
return true;
}
}
package com.example.restajunior;
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.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
public class MENUActivity extends Activity {
Button cemilan;
Button minumanbtn;
Button logoutbtn;
Button cemilan;
Button minumanbtn;
Button logoutbtn;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_menu);
cemilan = (Button) findViewById(R.id.Cemilanbtn);
Button minuman = (Button) findViewById(R.id.minumanbtn);
Button logout = (Button) findViewById(R.id.logoutbtn);
cemilan.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
Intent i = new Intent(MENUActivity.this,CemilanActivity.class);
i.putExtra("pesan","sukses login");
startActivity(i);
}
});
}
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_menu);
cemilan = (Button) findViewById(R.id.Cemilanbtn);
Button minuman = (Button) findViewById(R.id.minumanbtn);
Button logout = (Button) findViewById(R.id.logoutbtn);
cemilan.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
Intent i = new Intent(MENUActivity.this,CemilanActivity.class);
i.putExtra("pesan","sukses login");
startActivity(i);
}
});
}
@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_menu, menu);
return true;
}
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;
}
}
package com.example.restajunior;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.RadioButton;
import android.widget.TextView;
import android.widget.Toast;
import android.app.Activity;
import android.view.Menu;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.RadioButton;
import android.widget.TextView;
import android.widget.Toast;
public class CemilanActivity extends Activity {
RadioButton Rp;
RadioButton kentang;
RadioButton sosis;
Button ps;
Button total;
TextView jumlah,Total;
EditText et1;
int Hropang = 25000;
int Hkentang = 25000;
int Hsosis = 30000;
int harga ;
RadioButton Rp;
RadioButton kentang;
RadioButton sosis;
Button ps;
Button total;
TextView jumlah,Total;
EditText et1;
int Hropang = 25000;
int Hkentang = 25000;
int Hsosis = 30000;
int harga ;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_cemilan);
Rp = (RadioButton) findViewById (R.id.Ropang);
et1 = (EditText) findViewById (R.id.editText1);
kentang = (RadioButton) findViewById (R.id.kentanggoreng);
sosis = (RadioButton) findViewById (R.id.anekasosis);
jumlah = (TextView) findViewById (R.id.jumlah);
Total = (TextView) findViewById (R.id.Total);
ps = (Button) findViewById (R.id.proses);
total = (Button) findViewById (R.id.keluar);
ps.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
}
// TODO Auto-generated method stub
String pilihan =" Ropang" ;
String ket =" Total :";
int ps = Interger.parseInt(et1.getText().toString);
if (kentanggoreng.getid()){
int Total = Hkentang*ps;
pilihan = pilihan +" Ropang" + kentang +" "+ket +total;
total.setText(""+Totalharga);
}else {Totalharga = kentanggoreng *ps ;
pilihan = pilihan +" kentanggoreng" + ropang +" "+ket +total;
total.setText(""+Totalharga);
}else {Totalharga = anekasosis *ps ;
pilihan = pilihan +" anekasosis" + ropang +" "+ket +total;
total.setText(""+Totalharga);
}
Toast.maketext(getApplicationContext()) jumlah, Toast.LENGTH_LONG.show();
}
proses.
}); {
}
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_cemilan);
Rp = (RadioButton) findViewById (R.id.Ropang);
et1 = (EditText) findViewById (R.id.editText1);
kentang = (RadioButton) findViewById (R.id.kentanggoreng);
sosis = (RadioButton) findViewById (R.id.anekasosis);
jumlah = (TextView) findViewById (R.id.jumlah);
Total = (TextView) findViewById (R.id.Total);
ps = (Button) findViewById (R.id.proses);
total = (Button) findViewById (R.id.keluar);
ps.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
}
// TODO Auto-generated method stub
String pilihan =" Ropang" ;
String ket =" Total :";
int ps = Interger.parseInt(et1.getText().toString);
if (kentanggoreng.getid()){
int Total = Hkentang*ps;
pilihan = pilihan +" Ropang" + kentang +" "+ket +total;
total.setText(""+Totalharga);
}else {Totalharga = kentanggoreng *ps ;
pilihan = pilihan +" kentanggoreng" + ropang +" "+ket +total;
total.setText(""+Totalharga);
}else {Totalharga = anekasosis *ps ;
pilihan = pilihan +" anekasosis" + ropang +" "+ket +total;
total.setText(""+Totalharga);
}
Toast.maketext(getApplicationContext()) jumlah, Toast.LENGTH_LONG.show();
}
proses.
}); {
}
@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_cemilan, menu);
return true;
}
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.activity_cemilan, menu);
return true;
}
}
3.lalu kita Run dengan cara klik kanan ==> pilih RUN AS -->run configuration.
selesai selamat mencoba. terima kasih
Tidak ada komentar:
Posting Komentar