Skip to content

Commit

Permalink
Color background tint
Browse files Browse the repository at this point in the history
  • Loading branch information
romadebrian committed Jan 10, 2022
1 parent 7700d66 commit 05ee809
Show file tree
Hide file tree
Showing 4 changed files with 86 additions and 43 deletions.
79 changes: 53 additions & 26 deletions app/src/main/java/com/roma/kalkulatorpersen/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,21 @@

import androidx.appcompat.app.AppCompatActivity;

import android.graphics.Color;
import android.os.Bundle;
import android.renderscript.Script;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.Toast;

public class MainActivity extends AppCompatActivity {
View Form1;
EditText Jumlah, Persen, Hasil, Jumlah2, Berapa, Hasil2;
Button Hitung, Hitung2, Mode1, Mode2;
ImageView Footer;


@Override
Expand All @@ -35,34 +38,36 @@ protected void onCreate(Bundle savedInstanceState) {
Hasil2 = findViewById(R.id.Frm_Input_Hasil2);
Hitung2 = findViewById(R.id.Frm_Btn_Hitung2);

Footer = findViewById(R.id.Frm_Img_Footer);


// Hitung.setOnClickListener(new View.OnClickListener() {
// @Override
// public void onClick(View view) {
// String input1 = Jumlah.getText().toString();
// String input2 = Persen.getText().toString();
//
// if (input1.length() == 0) {
// Toast.makeText(MainActivity.this, "Jumlah Tidak Boleh Kosong", Toast.LENGTH_SHORT).show();
// return;
// }
// else if (input2.length() == 0) {
// Toast.makeText(MainActivity.this, "Persen Tidak Boleh Kosong", Toast.LENGTH_SHORT).show();
// return;
// }
// else {
// int jumlah = Integer.parseInt(input1);
// int persen = Integer.parseInt(input2);
//
// int hasil = jumlah * persen / 100;
//
// Hasil.setText(String.valueOf(hasil));
// Log.d( "Hasilnya: ", String.valueOf(hasil));
// }
//
// }
// });

Hitung.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
String input1 = Jumlah.getText().toString();
String input2 = Persen.getText().toString();

if (input1.length() == 0) {
Toast.makeText(MainActivity.this, "Jumlah Tidak Boleh Kosong", Toast.LENGTH_SHORT).show();
return;
}
else if (input2.length() == 0) {
Toast.makeText(MainActivity.this, "Persen Tidak Boleh Kosong", Toast.LENGTH_SHORT).show();
return;
}
else {
int jumlah = Integer.parseInt(input1);
int persen = Integer.parseInt(input2);

int hasil = jumlah * persen / 100;

Hasil.setText(String.valueOf(hasil));
Log.d( "Hasilnya: ", String.valueOf(hasil));
}

}
});

Hitung2.setOnClickListener(new View.OnClickListener() {
@Override
Expand Down Expand Up @@ -90,9 +95,31 @@ public void onClick(View v) {
});

Mode1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
findViewById(R.id.Frm_Include).setVisibility(View.VISIBLE);
findViewById(R.id.Frm_Include2).setVisibility(View.GONE);

Mode1.setBackgroundColor(Color.parseColor("#018786"));
Mode2.setBackgroundColor(Color.parseColor("#6200EE"));
}
});

Mode2.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
findViewById(R.id.Frm_Include).setVisibility(View.GONE);
findViewById(R.id.Frm_Include2).setVisibility(View.VISIBLE);

Mode1.setBackgroundColor(Color.parseColor("#6200EE"));
Mode2.setBackgroundColor(Color.parseColor("#018786"));
}
});

Footer.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(MainActivity.this, "Created by Roma Debrian", Toast.LENGTH_SHORT).show();
}
});
}
Expand Down
20 changes: 15 additions & 5 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<LinearLayout
android:layout_width="match_parent"
android:layout_height="60dp"
android:background="@color/purple_500"
android:background="#6200EE"
android:orientation="horizontal">

<TextView
Expand All @@ -38,7 +38,7 @@
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="end"
android:background="@color/teal_700"
android:background="#018786"
android:gravity="center"
android:text="Persen 1"
android:textColor="#FFFFFF"
Expand All @@ -50,7 +50,7 @@
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="end"
android:background="@color/teal_700"
android:background="#6200EE"
android:gravity="center"
android:text="Persen 2"
android:textColor="#FFFFFF"
Expand All @@ -66,18 +66,28 @@
android:layout_marginTop="15dp"
android:layout_marginRight="40dp"
android:layout_weight="1"
android:background="@color/white">
android:background="@color/white"
android:orientation="vertical">

<include
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/Frm_Include"
layout="@layout/persen_2"/>
layout="@layout/persen_1"
android:visibility="visible"/>

<include
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/Frm_Include2"
layout="@layout/persen_2"
android:visibility="gone"/>

</LinearLayout>

<!-- footer -->
<ImageView
android:id="@+id/Frm_Img_Footer"
android:layout_width="match_parent"
android:layout_height="100dp"
android:scaleType="centerCrop"
Expand Down
15 changes: 9 additions & 6 deletions app/src/main/res/layout/persen_1.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,10 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:minHeight="48dp"
android:backgroundTint="#4CAF50"
android:hint="1000"
android:inputType="number"
android:hint="0"
android:minHeight="48dp"
android:textColor="@color/black"
android:textSize="16sp" />
</LinearLayout>
Expand All @@ -48,9 +49,10 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:minHeight="48dp"
android:backgroundTint="#4CAF50"
android:hint="5"
android:inputType="number"
android:hint="0"
android:minHeight="48dp"
android:textColor="@color/black"
android:textSize="16sp" />
</LinearLayout>
Expand Down Expand Up @@ -79,9 +81,10 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:minHeight="48dp"
android:backgroundTint="#4CAF50"
android:hint="50"
android:inputType="number"
android:hint="0"
android:minHeight="48dp"
android:textColor="@color/black"
android:textSize="16sp" />
</LinearLayout>
Expand Down
15 changes: 9 additions & 6 deletions app/src/main/res/layout/persen_2.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,10 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:minHeight="48dp"
android:inputType="number"
android:backgroundTint="#4CAF50"
android:hint="0"
android:inputType="number"
android:minHeight="48dp"
android:textColor="@color/black"
android:textSize="16sp" />
</LinearLayout>
Expand All @@ -48,9 +49,10 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:minHeight="48dp"
android:inputType="number"
android:backgroundTint="#4CAF50"
android:hint="0"
android:inputType="number"
android:minHeight="48dp"
android:textColor="@color/black"
android:textSize="16sp" />
</LinearLayout>
Expand Down Expand Up @@ -79,9 +81,10 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:minHeight="48dp"
android:inputType="number"
android:backgroundTint="#4CAF50"
android:hint="0"
android:inputType="number"
android:minHeight="48dp"
android:textColor="@color/black"
android:textSize="16sp" />
</LinearLayout>
Expand Down

0 comments on commit 05ee809

Please sign in to comment.