NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

java
package com.example.dimasilyas.dimaaas;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.Spinner;
import android.widget.Switch;
import android.widget.TextView;
import android.widget.Toast;

public class MainActivity extends AppCompatActivity implements View.OnClickListener{


private TextView tampildata;
private EditText txtnama;
private RadioGroup radiojkgroup;
private RadioButton radiojkbutton;
private Spinner agama;
private CheckBox spbola, basket, renang, voli;
private Button simpan, reset;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);


tampildata = (TextView) findViewById(R.id.tampildata);
txtnama =(EditText) findViewById(R.id.txtnama);
radiojkgroup = (RadioGroup) findViewById(R.id.radiojkgroup);
agama = (Spinner) findViewById(R.id.agama);
spbola = (CheckBox) findViewById(R.id.spbola);
basket = (CheckBox) findViewById(R.id.basket);
renang = (CheckBox) findViewById(R.id.renang);
voli = (CheckBox) findViewById(R.id.voli);

simpan = (Button) findViewById(R.id.simpan);
reset = (Button) findViewById(R.id.reset);

simpan.setOnClickListener(this);
reset.setOnClickListener(this);
}

@Override
public void onClick(View view) {
switch (view.getId()){
case R.id.simpan:
//jenis kelamin
int selectedId = radiojkgroup.getCheckedRadioButtonId();

radiojkbutton = (RadioButton) findViewById(selectedId);

//hobi
String hobi ="Hobi :";
if(spbola.isChecked()){
hobi += "nSepak Bola";
}
if(basket.isChecked()){
hobi += "nBasket";
}
if(renang.isChecked()){
hobi += "nRenang";
}
if(voli.isChecked()){
hobi += "nvoli";
}

Toast.makeText(this, "Data Berhasil DiSimpan!", Toast.LENGTH_SHORT).show();

tampildata.setText("Nama : " + txtnama.getText()
+ "nJenis Kelamin : " + radiojkbutton.getText()
+ "nAgama : " + agama.getSelectedItem().toString()
+ "n" + hobi);
break;

case R.id.reset:
tampildata.setText(null);
txtnama.setText(null);
radiojkgroup.clearCheck();
agama.setSelection(0);
spbola.setChecked(false);
basket.setChecked(false);
renang.setChecked(false);
voli.setChecked(false);
break;
}

}
}




index
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity"
android:padding="16dp"
>
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="BIODATA MAHASISWA"
android:textAlignment="center"
android:textSize="20dp" />


<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Nama"
android:textSize="20dp" />

<EditText
android:id="@+id/txtnama"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Masukkan Nama" />

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Jenis Kelamin"
android:textSize="20dp" />

<RadioGroup
android:id="@+id/radiojkgroup"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">

<RadioButton
android:id="@+id/rdlk"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Laki-Laki" />

<RadioButton
android:id="@+id/rdpr"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Perempuan" />
</RadioGroup>

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Agama"
android:textSize="20dp" />

<Spinner
android:id="@+id/agama"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:entries="@array/agama">

</Spinner>

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Hobi"
android:textSize="20dp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<CheckBox
android:id="@+id/spbola"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Sepak Bola"
android:layout_weight="1"/>

<CheckBox
android:id="@+id/basket"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Basket"
android:layout_weight="1"/>
</LinearLayout>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">

<CheckBox
android:id="@+id/renang"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:text="Renang" />

<CheckBox
android:id="@+id/voli"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Voli" />
</LinearLayout>


<Button
android:id="@+id/simpan"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="simpan"/>
<Button
android:id="@+id/reset"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="Reset"/>
<TextView
android:id="@+id/tampildata"
android:layout_width="match_parent"
android:layout_height="wrap_content" />

</LinearLayout>
</ScrollView>
</RelativeLayout>
     
 
what is notes.io
 

Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 12 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.