LABORATORIUM KOMPUTER & JARINGAN SEKOLAH TINGGI MANAJEMEN INFORMATIKA DAN KOMPUTER AMIKOM PURWOKERTO JL. LET. JEND. POL SUMARTO PURWOKERTO 2013
4. Pilih tempat menyimpan project kita dengan menghilangkan tanda cecklist di Create Project in Workspace,klik ceklist dan Next.
8.
video.setIndicator("Video",getResources().getDrawable(R.drawable.tabv ideo)); Intent videoIntent=new Intent(this, video.class); video.setContent(videoIntent); tabhost.addTab(foto); tabhost.addTab(file); tabhost.addTab(video); } }
10.
11.
Pada Class Foto.java ketikan kode berikut : package com.example.androidtab; import android.app.Activity; import android.os.Bundle; publicclass foto extends Activity{ @Override protectedvoid onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.foto); } }
12.
Pada Activity_main.xml ketikan kode berikut: <?xmlversion="1.0"encoding="utf-8"?> <TabHostxmlns:android="http://schemas.android.com/apk/res/android" android:id="@android:id/tabhost" android:layout_width="fill_parent" android:layout_height="fill_parent"> <LinearLayout android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent"> <TabWidget android:id="@android:id/tabs" android:layout_width="fill_parent" android:layout_height="wrap_content"/> <FrameLayout android:id="@android:id/tabcontent" android:layout_width="fill_parent" android:layout_height="fill_parent"/> </LinearLayout> </TabHost>
13.
Pada Video.xml ketikan kode berikut : <?xmlversion="1.0"encoding="utf-8"?> <LinearLayoutxmlns:android="http://schemas.android.com/apk/res/androi d" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <TextView android:text="Tab video" android:padding="15dip" android:textSize="18dip" android:layout_width="fill_parent" android:layout_height="wrap_content" /> <RelativeLayout android:layout_width="match_parent" android:layout_height="match_parent"> <ImageView android:id="@+id/imageView1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentTop="true" android:layout_centerHorizontal="true" android:layout_marginTop="83dp" android:src="@drawable/video_klik"/> </RelativeLayout> </LinearLayout>
14.
Pada Foto.xml ketikan kode berikut : <?xmlversion="1.0"encoding="utf-8"?> <LinearLayoutxmlns:android="http://schemas.android.com/apk/res/androi d" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <TextView android:text="Tab foto" android:padding="15dip" android:textSize="18dip" android:layout_width="fill_parent" android:layout_height="wrap_content" /> <RelativeLayout android:layout_width="match_parent" android:layout_height="match_parent"> <ImageView android:id="@+id/imageView1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentLeft="true" android:layout_alignParentTop="true" android:layout_marginTop="34dp" android:src="@drawable/foto_klik"/> </RelativeLayout> </LinearLayout>
15.
Pada File.xml ketikan kode berikut : <?xmlversion="1.0"encoding="utf-8"?> <LinearLayoutxmlns:android="http://schemas.android.com/apk/res/androi d" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:padding="15dip" android:text="Tab file" android:textSize="18dip"/> <RelativeLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="1.13"> <ImageView android:id="@+id/imageView1" android:layout_width="wrap_content"
17. Setelah itu tekan CTRL SHIFT S atau Save All,dan pilih menu Window AVD (Android Virtual Device Manager),klik New dan isikan sesuka kita,pilih Device Target,CPU,dan OK.
20. Dan jalankan project yang telah kita buat dengan klik kanan pada project tersebut,pilih RUN AS Android Aplication.Maka akan muncul Project yang anda buat.Dan jika di klik salah satu akan muncul seperti ini :
SEKIAN