Sabtu, 22 Juli 2017

Tugas Membuat Aplikasi Tab_View Android dengan eclipse

Nama : Rinaldi Sandria
Kelas : 06 TPLM014
NIM  : 2014141842

1. jika telah masuk kedalam aplikasi eclipse yang sedang dijalankan maka selanjutnya kita buat sebuah project baru dengan nama Tab_view
Ini adalah Source Codenya:

<?xml version=“1.0” encoding=“utf-8”?>
<LinearLayout xmlns:android=http://schemas.android.com/apk/res/android&#8221;
android:layout_width=“fill_parent”
android:layout_height=“fill_parent”
android:orientation=“vertical” > 
<AbsoluteLayout
android:layout_width=“match_parent”
android:layout_height=“wrap_content”
android:layout_weight=“0.78” >
<TabHost
android:id=“@+id/tabHost”
android:layout_width=“match_parent”
android:layout_height=“match_parent”
android:layout_x=“0dp”
android:layout_y=“0dp” >
 <LinearLayout
 android:layout_width=“match_parent”
 android:layout_height=“match_parent”
android:orientation=“vertical” > 
<TabWidget
android:id=“@android:id/tabs”
android:layout_width=“match_parent”
android:layout_height=“wrap_content” 
</TabWidget>
                <FrameLayout
                    android:id=“@android:id/tabcontent”
                    android:layout_width=“match_parent”
                    android:layout_height=“match_parent” >
                    <LinearLayout
                        android:id=“@+id/tab1”
                        android:layout_width=“match_parent”
                        android:layout_height=“match_parent”
                        android:contentDescription=“HOME” >
                            <TextView
                        android:id=“@+id/textView1”
                        android:layout_width=“204dp”
                        android:layout_height=“match_parent”
                        android:paddingLeft=“10dp”
                        android:text=“Nama : Candra Yogi Hananto
                                    Tanggal Lahir : 1 juli 1994
                                    Alamat : Pageraji,Cilongok
                                    No.Hp : 085728717729
                                    Jenis Kelamin : Laki-Laki
                                    “/>
                        </LinearLayout>
                    <LinearLayout
                        android:id=“@+id/tab2”
                        android:layout_width=“match_parent”
                        android:layout_height=“match_parent”
                        android:contentDescription=“HOME” >
                            <TextView
                         android:id=“@+id/textView2”
                         android:layout_width=“204dp”
                         android:layout_height=“match_parent”
                         android:paddingLeft=“10dp”
                         android:text=“Berharap mendapat nilai yang baik,
                          Lulus Kuliah dengan waktu yang ditargetkan,
                         Mendapatkan ilmu yang bermanfaat,
                        Dapat lebih disiplin dalam segala hal,
                         Lebih memanfaatkan waktu dengan baik.
                         “/>
                        </LinearLayout>
                      <LinearLayout
                        android:id=“@+id/tab3”
                        android:layout_width=“match_parent”
                        android:layout_height=“match_parent”
                        android:contentDescription=“HOME” >
                            <TextView
                         android:id=“@+id/textView3”
                         android:layout_width=“204dp”
                            android:layout_height=“match_parent”
                            android:paddingLeft=“10dp”
                            android:text=“Mendengarkan musik
                                        Bermain game
                                        Membaca
                                        “/>
                        </LinearLayout>
                 </FrameLayout>
            </LinearLayout>
        </TabHost>
    </AbsoluteLayout>   
    </LinearLayout>
h.dan berikutnya setelah selesai memasukan code program di atas,langkah berikutnya kita masukan code program pada main activity.java seperti berikut ini package com.example.tab_view;
import android.os.Bundle;

import android.app.Activity;
import android.view.Menu;
import android.widget.TabHost;
import android.widget.TabHost.TabSpec;
public class MainActivity extends Activity {
      @Override
      protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
        TabHost tabHost=(TabHost)findViewById(R.id.tabHost);
        tabHost.setup();
        TabSpec spec1=tabHost.newTabSpec(“TAB 1”);
        spec1.setContent(R.id.tab1);
        spec1.setIndicator(“Biodata”);
        TabSpec spec2=tabHost.newTabSpec(“TAB 2”);
        spec2.setIndicator(“Harapan”);
        spec2.setContent(R.id.tab2);     
        TabSpec spec3=tabHost.newTabSpec(“TAB 3”);
        spec3.setContent(R.id.tab3);
        spec3.setIndicator(“Hobby”);
        tabHost.addTab(spec1);
        tabHost.addTab(spec2);
        tabHost.addTab(spec3);
      }
i.Dan setelah kita selesai mmengetikkan code program tersebut maka selanjutnya   kita save as project untuk melihat apakah masih ada code program yang masih    error atau tidak,dan jika semua code program telah benar maka kita jalankan    project tersebut dengan cara klik kanan pada project lalu pilih run as – android application dan tunggu hingga muncul program pada emulator.