Anda di halaman 1dari 12

TUGAS PEMROGRAMAN MOBILE TUTORIALTAB MENU TABHOST

DISUSUN OLEH : Ardhitya Lingga SI 12 A

LABORATORIUM KOMPUTER & JARINGAN SEKOLAH TINGGI MANAJEMEN INFORMATIKA DAN KOMPUTER AMIKOM PURWOKERTO JL. LET. JEND. POL SUMARTO PURWOKERTO 2013

Nah ini Langkah-langkahnya : 1. Pertama buka Eclipse.

2. Kemudian klik New Android Aplication.

3. Isi Aplication name (di awali dengan huruf kapital).Next.

4. Pilih tempat menyimpan project kita dengan menghilangkan tanda cecklist di Create Project in Workspace,klik ceklist dan Next.

5. Pilih icon sesuka kita,Next.

6. Pilih Blank Activity,Next.

7. Biarkan saja bagian ini,klik Finish.

8.

Masuk kemenu Main Activity,isikan code berikut :


package com.example.androidtab; import android.os.Bundle; importandroid.app.TabActivity; import android.content.Intent; import android.widget.TabHost; import android.widget.TabHost.TabSpec; publicclass MainActivity extendsTabActivity { @Override protectedvoid onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); TabHost tabhost=getTabHost(); TabSpec foto=tabhost.newTabSpec("Foto"); foto.setIndicator("Foto",getResources().getDrawable(R.drawable.tabfot o)); Intent fotoIntent=new Intent(this, foto.class); foto.setContent(fotoIntent); TabSpec file=tabhost.newTabSpec("File"); file.setIndicator("File",getResources().getDrawable(R.drawable.tabfil e)); Intent fileIntent=new Intent(this, file.class); file.setContent(fileIntent); TabSpec video=tabhost.newTabSpec("Video");

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); } }

9. Pada Class file.java ketikan kode berikut :


package com.example.androidtab; import android.app.Activity; import android.os.Bundle; publicclass file extends Activity{ @Override protectedvoid onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.file); } }

10.

Pada Class Video.java ketikan kode berikut :


package com.example.androidtab; import android.app.Activity; import android.os.Bundle; publicclass video extends Activity{ @Override protectedvoid onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.video); } }

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"

android:layout_height="wrap_content" android:layout_alignParentTop="true" android:layout_centerHorizontal="true" android:layout_marginTop="60dp" android:src="@drawable/file_klik"/> </RelativeLayout> </LinearLayout>

16. Pada AndroidManifest.xml ketikan kode berikut :


</activity> <activity android:name="com.example.androidtab.foto" android:label="@string/app_name"> </activity> <activity android:name="com.example.androidtab.file" android:label="@string/app_name"> </activity> <activity android:name="com.example.androidtab.video" android:label="@string/app_name"> </activity>

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.

18. Dan kik START,tunggu sebentar.

19. Lalu akan muncul Emulator Androidnya seperti berikut.

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

Anda mungkin juga menyukai