Created
September 24, 2024 23:14
-
-
Save yasriady/b73585bd8860c1ea2d84f0d1a8dcbcf5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
xmlns:app="http://schemas.android.com/apk/res-auto" | |
xmlns:tools="http://schemas.android.com/tools" | |
android:id="@+id/main" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" | |
android:orientation="vertical" | |
android:padding="16dp" | |
tools:context="com.example.mahasiswa.MainActivity"> | |
<EditText | |
android:id="@+id/inputNama" | |
android:layout_width="match_parent" | |
android:layout_height="wrap_content" | |
android:hint="Nama" | |
android:inputType="textPersonName" | |
android:textSize="16sp" /> | |
<EditText | |
android:id="@+id/inputNik" | |
android:layout_width="match_parent" | |
android:layout_height="wrap_content" | |
android:hint="Nomor Induk Kependudukan" | |
android:inputType="number" | |
android:textSize="16sp" /> | |
<EditText | |
android:id="@+id/inputUmur" | |
android:layout_width="match_parent" | |
android:layout_height="wrap_content" | |
android:hint="Umur" | |
android:inputType="number" | |
android:textSize="16sp" /> | |
<EditText | |
android:id="@+id/inputAlamat" | |
android:layout_width="match_parent" | |
android:layout_height="wrap_content" | |
android:hint="Alamat" | |
android:inputType="text" | |
android:textSize="16sp" /> | |
<EditText | |
android:id="@+id/inputAsalSekolah" | |
android:layout_width="match_parent" | |
android:layout_height="wrap_content" | |
android:hint="Asal Sekolah" | |
android:inputType="textCapWords" | |
android:textSize="16sp" /> | |
<Button | |
android:id="@+id/simpan_button" | |
android:layout_width="match_parent" | |
android:layout_height="wrap_content" | |
android:onClick="save" | |
android:text="Save" | |
android:textAllCaps="true" | |
android:textSize="16sp" /> | |
<LinearLayout | |
android:layout_width="match_parent" | |
android:layout_height="180dp" | |
android:background="#eceff1" | |
android:orientation="horizontal"> | |
<LinearLayout | |
android:layout_width="wrap_content" | |
android:layout_height="match_parent" | |
android:layout_marginLeft="8dp" | |
android:layout_marginTop="8dp" | |
android:orientation="vertical"> | |
<TextView | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:layout_weight="1" | |
android:text="Nama" /> | |
<TextView | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:layout_weight="1" | |
android:text="NIK" /> | |
<TextView | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:layout_weight="1" | |
android:text="Umur" /> | |
<TextView | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:layout_weight="1" | |
android:text="Alamat" /> | |
<TextView | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:layout_weight="1" | |
android:text="Asal Sekolah" /> | |
</LinearLayout> | |
<LinearLayout | |
android:layout_width="wrap_content" | |
android:layout_height="match_parent" | |
android:layout_marginLeft="8dp" | |
android:layout_marginTop="8dp" | |
android:orientation="vertical"> | |
<TextView | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:layout_weight="1" | |
android:text=":" /> | |
<TextView | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:layout_weight="1" | |
android:text=":" /> | |
<TextView | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:layout_weight="1" | |
android:text=":" /> | |
<TextView | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:layout_weight="1" | |
android:text=":" /> | |
<TextView | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:layout_weight="1" | |
android:text=":" /> | |
</LinearLayout> | |
<LinearLayout | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" | |
android:layout_marginLeft="8dp" | |
android:layout_marginTop="8dp" | |
android:orientation="vertical"> | |
<TextView | |
android:id="@+id/txtNama" | |
android:layout_width="match_parent" | |
android:layout_height="wrap_content" | |
android:layout_weight="1" /> | |
<TextView | |
android:id="@+id/txtNik" | |
android:layout_width="match_parent" | |
android:layout_height="wrap_content" | |
android:layout_weight="1" /> | |
<TextView | |
android:id="@+id/txtUmur" | |
android:layout_width="match_parent" | |
android:layout_height="wrap_content" | |
android:layout_weight="1" /> | |
<TextView | |
android:id="@+id/txtAlamat" | |
android:layout_width="match_parent" | |
android:layout_height="wrap_content" | |
android:layout_weight="1" /> | |
<TextView | |
android:id="@+id/txtAsalSekolah" | |
android:layout_width="match_parent" | |
android:layout_height="wrap_content" | |
android:layout_weight="1" /> | |
</LinearLayout> | |
</LinearLayout> | |
</LinearLayout> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.example.mahasiswa; | |
import android.os.Bundle; | |
import android.view.View; | |
import android.widget.EditText; | |
import android.widget.TextView; | |
import androidx.activity.EdgeToEdge; | |
import androidx.appcompat.app.AppCompatActivity; | |
import androidx.core.graphics.Insets; | |
import androidx.core.view.ViewCompat; | |
import androidx.core.view.WindowInsetsCompat; | |
public class MainActivity extends AppCompatActivity { | |
private EditText mNama; | |
private EditText mNik; | |
private EditText mUmur; | |
private EditText mAlamat; | |
private EditText mAsalSekolah; | |
private TextView tNama; | |
private TextView tNik; | |
private TextView tUmur; | |
private TextView tAlamat; | |
private TextView tAsalSekolah; | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
EdgeToEdge.enable(this); | |
setContentView(R.layout.activity_main); | |
ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main), (v, insets) -> { | |
Insets systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars()); | |
v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom); | |
return insets; | |
}); | |
mNama = findViewById(R.id.inputNama); | |
mNik = findViewById(R.id.inputNik); | |
mUmur = findViewById(R.id.inputUmur); | |
mAlamat = findViewById(R.id.inputAlamat); | |
mAsalSekolah = findViewById(R.id.inputAsalSekolah); | |
tNama = findViewById(R.id.txtNama); | |
tNik = findViewById(R.id.txtNik); | |
tUmur = findViewById(R.id.txtUmur); | |
tAlamat = findViewById(R.id.txtAlamat); | |
tAsalSekolah = findViewById(R.id.txtAsalSekolah); | |
} | |
public void save(View view) { | |
String nama = mNama.getText().toString(); | |
String nik = mNik.getText().toString(); | |
String umur = mUmur.getText().toString(); | |
String alamat = mAlamat.getText().toString(); | |
String asalSekolah = mAsalSekolah.getText().toString(); | |
tNama .setText(nama); | |
tNik.setText(nik); | |
tUmur.setText(umur); | |
tAlamat.setText(alamat); | |
tAsalSekolah.setText(asalSekolah); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment