Activity - Main - HTML: Linearlayout
Activity - Main - HTML: Linearlayout
Activity - Main - HTML: Linearlayout
html
<ImageView
android:id="@+id/gmbr"
android:layout_width="match_parent"
android:layout_height="150sp"
android:textAlignment="center"
android:textSize="50sp"
android:layout_margin="40dp"/>
<TextView
android:id="@+id/username"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Masukan Username"
android:textColor="#000000"
android:textSize="20sp"
android:layout_marginHorizontal="50dp"/>
<EditText
android:id="@+id/username2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Username"
android:textColorHint="#000"
android:layout_marginHorizontal="50dp"/>
<TextView
android:id="@+id/password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Masukan Password :"
android:textColor="#000"
android:textSize="20sp"
android:layout_marginHorizontal="50dp"/>
<EditText
android:id="@+id/password2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Password"
android:textColorHint="#000"
android:inputType="textPassword"
android:layout_marginHorizontal="50dp"/>
<CheckBox
android:id="@+id/boxx"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="show password"
android:textColor="#000" />
<Button
android:id="@+id/button"
android:layout_width="150sp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="Login"
android:textSize="15sp" />
<Button
android:id="@+id/button2"
android:layout_width="150sp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="Register"
android:textSize="15sp" />
<TextView
android:id="@+id/tampil"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
Activity_Main2.html
<EditText
android:layout_width="match_parent"
android:layout_height="match_parent"
android:hint="Masukan nama anda"
android:id="@+id/edt_name"
android:inputType="text"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Choffe"
android:layout_gravity="center"
android:textSize="25dp"/>
<CheckBox
android:id="@+id/Arabica"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Exspresso"
android:paddingLeft="16dp"
android:textSize="15sp"/>
<CheckBox
android:id="@+id/Chocolate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Chocolate"
android:paddingLeft="16dp"
android:textSize="15sp"/>
<CheckBox
android:id="@+id/Arabica_Chocolate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Capuccino"
android:textSize="15sp"
android:paddingLeft="16dp"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="jumlah"
android:textSize="25dp"
android:textAllCaps="true"
android:layout_marginBottom="16dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<Button
android:layout_width="48dp"
android:onClick="increment"
android:text="+"
android:layout_height="48dp" />
<TextView
android:textColor="#212121"
android:layout_gravity="center"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="0"
android:paddingRight="8dp"
android:paddingLeft="8dp"
android:id="@+id/quantity_textview"
android:textSize="25dp"/>
<Button
android:layout_width="48dp"
android:onClick="decrement"
android:text="-"
android:layout_height="48dp" />
</LinearLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Harga"
android:textSize="30dp"
android:textAllCaps="true"
android:layout_marginBottom="16dp"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="0"
android:textColor="#212121"
android:id="@+id/price_textview"
android:textSize="25dp"/>
<Button
android:layout_width="wrap_content"
android:layout_marginBottom="16dp"
android:onClick="Submitorder"
android:layout_height="wrap_content"
android:text="Order"/>
</LinearLayout>
</ScrollView>
MainActivity.java
package com.kmftapp.tes;
import android.content.Intent;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
btnLogin.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
});
}
}
main2activity.java
package com.kmftapp.tes;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.View;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
import java.text.NumberFormat;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main2);
}
public void increment(View view){//perintah tombol tambah
if(quantity==100){
Toast.makeText(this,"pesanan maximal 100",Toast.LENGTH_SHORT).show();
return;
}
quantity = quantity+1 ;
display(quantity);
}
public void decrement(View view){//perintah tombol tambah
if (quantity==1){
}
public void Submitorder(View view) {
EditText nameEditText=(EditText)findViewById(R.id.edt_name);
String name=nameEditText.getText().toString();
Log.v("Main2Activity","Nama:"+name);
CheckBox ArabicaCheckBox=(CheckBox)findViewById(R.id.Arabica);
boolean hasArabica=ArabicaCheckBox.isChecked();
Log.v("Main2Activity","has Arabica: "+hasArabica);
displayMessage(pricemessage);
}
}
if (addchocolate){
harga=harga+4000;
}
if (addarabicachocolate){
harga=harga+5000;
}
return quantity * harga;
}
private String createOrderSummary(int price, String name, boolean Benar, boolean Yakin, boolean
Sungguh) {
String pricemessage=" Nama :"+name;
pricemessage+="\n Apakah Anda ingin Menambahkan arabica?";
pricemessage+="\n Apakah Anda ingin Menambahkan Chocolate?";
pricemessage+="\n Apakah Anda Ingin Menambahkan ArabicaChocolate ?";
pricemessage+="\n Jumlah"+quantity;
pricemessage+="\n Total Rp"+price;
pricemessage+="\n Thankyou ";
return pricemessage;
}
private void displayMessage(String massage){
TextView priceTextView =(TextView)findViewById(R.id.price_textview);
priceTextView.setText(massage);
}
private void display(int number){
TextView quantityTextView = (TextView) findViewById(R.id.quantity_textview);
quantityTextView.setText("" + number);
}
private void displayPrice(int number) {
TextView priceTextView = (TextView) findViewById(R.id.price_textview);
priceTextView.setText(NumberFormat.getCurrencyInstance().format(number));
}
}