• Tidak ada hasil yang ditemukan

UNIVERSITAS KOMPUTER INDONESIA

N/A
N/A
Protected

Academic year: 2024

Membagikan "UNIVERSITAS KOMPUTER INDONESIA"

Copied!
15
0
0

Teks penuh

(1)

UNIVERSITAS KOMPUTER INDONESIA

(2)

BAB III.

HELLO WORLD

Dosen Pembina :

Bella Hardiyana, S. Kom, M. Kom

(3)

HelloWorld1 (1)

Buatlah sebuah proyek baru dengan spesifikasi dibawah ini :

(4)

HelloWorld1 (2)

MainActivity.java

package com.latihan.hello1;

import android.os.Bundle;

import android.app.Activity;

import android.view.Menu;

public class MainActivity extends Activity { @Override

protected void onCreate(Bundle savedInstanceState) { //metode wajib ada super.onCreate(savedInstanceState);

setContentView(R.layout.activity_main);

}

@Override

public boolean onCreateOptionsMenu(Menu menu) { //metode opsional // Inflate the menu; this adds items to the action bar if it is present.

getMenuInflater().inflate(R.menu.main, menu);

return true;

}

(5)

HelloWorld1 (3)

activity_main.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"

xmlns:tools="http://schemas.android.com/tools"

android:layout_width="match_parent"

android:layout_height="match_parent"

android:paddingBottom="@dimen/activity_vertical_margin"

android:paddingLeft="@dimen/activity_horizontal_margin"

android:paddingRight="@dimen/activity_horizontal_margin"

android:paddingTop="@dimen/activity_vertical_margin"

tools:context=".MainActivity" >

<TextView

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:text="@string/hello_world" />

</RelativeLayout>

(6)

HelloWorld1 (4)

R.java

package com.latihan.hello1;

public final class R {

public static final class attr { }

public static final class dimen {

public static final int activity_horizontal_margin=0x7f040000;

public static final int activity_vertical_margin=0x7f040001;

}

public static final class drawable {

public static final int ic_launcher=0x7f020000;

}

public static final class id {

public static final int action_settings=0x7f080000;

}

public static final class layout {

public static final int activity_main=0x7f030000;

}

public static final class menu {

public static final int main=0x7f070000;

}

public static final class string {

public static final int action_settings=0x7f050001;

public static final int app_name=0x7f050000;

public static final int hello_world=0x7f050002;

}

public static final class style {

public static final int AppBaseTheme=0x7f060000;

public static final int AppTheme=0x7f060001;

} }

(7)

HelloWorld2 (1)

Buatlah sebuah proyek baru dengan spesifikasi dibawah ini :

(8)

HelloWorld2 (2)

MainActivity.java

package com.latihan.hello2;

import android.os.Bundle;

import android.widget.TextView;

import android.app.Activity;

public class MainActivity extends Activity { @Override

protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState);

TextView txtHello = new TextView(this);

txtHello.setText("Hello World!");

setContentView(txtHello);

}

}

(9)

HelloWorld2 (3)

activity_main.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"

xmlns:tools="http://schemas.android.com/tools"

android:layout_width="match_parent"

android:layout_height="match_parent"

android:paddingBottom="@dimen/activity_vertical_margin"

android:paddingLeft="@dimen/activity_horizontal_margin"

android:paddingRight="@dimen/activity_horizontal_margin"

android:paddingTop="@dimen/activity_vertical_margin"

tools:context=".MainActivity" >

//Hapus TextView

</RelativeLayout>

(10)

HelloWorld3 (1)

Buatlah sebuah proyek baru dengan spesifikasi dibawah ini :

(11)

HelloWorld3 (2)

activity_main.xml

<LinearLayout

xmlns:android="http://schemas.android.com/apk/res/android"

xmlns:tools="http://schemas.android.com/tools"

android:layout_width="match_parent"

android:layout_height="match_parent"

android:orientation="vertical" >

<TextView

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:text="TextView" />

<TextView

android:layout_width="fill_parent"

android:layout_height="wrap_content"

android:text="Large Text"

android:background="#ff0000ff"

android:textColor="#ff00ff00"

android:textAppearance="?android:attr/textAppearanceLarge" />

<TextView

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:text="Medium Text"

android:textColor="#ffffff00"

android:textAppearance="?android:attr/textAppearanceMedium"

/>

<TextView

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:text="Small Text"

android:textColor="#abcdef"

android:textAppearance="?android:attr/textAppearanceSmall" />

<TextView

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_gravity="center_horizontal"

android:text="Teks 1"

android:textSize="10dp" />

<TextView

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_gravity="left"

android:text="Teks 2"

android:textSize="15dp" />

<TextView

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_gravity="right"

android:text="Teks 3"

android:textSize="20dp" />

<TextView

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:text="@string/hello_world" />

<TextView

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:text="@string/halo_bandung" />

</LinearLayout>

(12)

HelloWorld3 (3)

UI dari activity_main.xml

(13)

HelloWorld3 (4)

strings.xml

<?xml version="1.0" encoding="utf-8"?>

<resources>

<string name="app_name">Hello World 3</string>

<string name="action_settings">Settings</string>

<string name="hello_world">Hello world!</string>

<string name="halo_bandung">Halo Kota Bandung</string>

</resources>

(14)

HelloWorld3 (5)

(15)

Terima Kasih

Referensi

Dokumen terkait

Select/blok sel yang ingin dipindahkan, dan geser ke tempat yang diinginkan. Menu Insert Column akan menambahkan

Rumus merupakan bagian terpenting dari Program Microsoft Excel , karena setiap tabel dan dokumen yang kita ketik akan selalu berhubungan dengan rumus dan fungsi...

Berdasarkan hasil analisis, wawancara dan kuesioner yang sudah dilakukan maka dapat dilihat pemetaan tingkat kamatangan atribut pengukuran area Komunikasi (COM) dapat di

Sedangkan dalam menu latihan kata sederhana berisi latihan kata – kata sederhana yang akan meminta user untuk mengulang kata sederhana yang telah diucapkan oleh

Menu Register merupakan menu untuk pendaftaran pengguna yang berfungsi untuk menghubungkan data pribadi pada aplikasi WebStorage tersebut, seperti yang dapat

Tambang Batubara Bukit Asam pada tahun 2012 mengalami kenaikan volume penjualan US$ 31, 929 ribu dan mengalami penurunan biaya operasional sebesar US$ 15,055 ribu, ini

▪ Melakukan pengkodean program dalam bahasa PHP dan Java untuk membangun aplikasi berbasis web dan aplikasi daemon service ▪ Melakukan instalasi dan konfigurasi server

Tampilan Menu Utama 4.3 Tampilan Main Menu Merupakan tampilan pada saat pengguna memilih Main Menu maka pengguna akan memasuki tampilan menu baru yang menampilkan 4 kategori pilihan