Koding.pdf

  • Uploaded by: Taqi Rafifianto
  • 0
  • 0
  • October 2019
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Koding.pdf as PDF for free.

More details

  • Words: 256
  • Pages: 3
Tabel 1: activity_main.xml activity_main.xml <EditText android:id="@+id/panjang" android:layout_width="match_parent" android:layout_height="wrap_content" android:ems="10" android:inputType="number" android:text="@string/input_panjang" > <requestFocus /> <EditText android:id="@+id/lebar" android:layout_width="match_parent" android:layout_height="wrap_content" android:ems="10"

android:inputType="number" android:text="@string/input_lebar" /> <Button android:id="@+id/hitung" android:layout_width="284dp" android:layout_height="wrap_content" android:text="@string/button_hitung" /> <Button android:id="@+id/kosong" android:layout_width="280dp" android:layout_height="wrap_content" android:text="@string/kosong3" />


Tabel 2: strings.xml strings.xml <string <string <string <string <string <string <string <string <string <string <string <string <string <string <string <string

name="app_name">Yuhu name="action_settings">Settings name="hello_world">Hello world! name="panjang">Panjang name="input_panjang"> name="lebar">Lebar name="input_lebar"> name="button_hitung">Hitung name="welcome">Selamat Datang name="ahaha">Menghitung Luas Persegi name="kosong"> name="kosong2"> name="luas">Luas Persegi: name="kosong3">Kosongkan name="title_activity_oyeah">Oyeah name="luas2">



Tabel 3: MainActivity.java MainActivity.java package com.example.yuhu;

import import import import import import import

android.os.Bundle; android.app.Activity; android.view.Menu; android.view.View; android.widget.Button; android.widget.EditText; android.widget.TextView;

public class MainActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); final final final final final

EditText panjang=(EditText) findViewById(R.id.panjang); EditText lebar=(EditText) findViewById(R.id.lebar); Button hitung=(Button) findViewById(R.id.hitung); Button kosong=(Button) findViewById(R.id.kosong); TextView hasil=(TextView) findViewById(R.id.luas);

hitung.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { int varPanjang=Integer.parseInt(panjang.getText().toString()); int varLebar=Integer.parseInt(lebar.getText().toString()); int luas=varPanjang*varLebar; hasil.setText("Luas Persegi: "+luas); } }); kosong.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { panjang.setText(null); lebar.setText(null); hasil.setText("Luas Persegi: "); } }); } @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.main, menu); return true; } }

More Documents from "Taqi Rafifianto"

Document.pdf
October 2019 4
Ask.pdf
May 2020 2
Koding.pdf
October 2019 4
Sawalnama.pdf
August 2019 7
August 2019 17
Shabaan Amaal Booklet.pdf
August 2019 13