LEAFLET

1. activity_main.xml untuk tampilan awalnya

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@drawable/poligon"
    tools:context=".MainActivity" >

    <Button
        android:id="@+id/btn_menu"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="390dp"
        android:text="Menu"
        android:textColor="#FF0000"
        android:textStyle="bold" />

</LinearLayout>

2. activity_main.xml untuk tampilan menu,, tuliskan script di bawah ini

<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:background="@drawable/bg_menu"
    tools:context=".MenuActivity" >
  
    <Button
        android:id="@+id/dosen"
        android:layout_width="100dp"
        android:layout_height="100dp"
        android:background="@drawable/dosen1"
        android:layout_marginLeft="30dp"
        android:layout_marginTop="150dp"
        /> 

 <Button
     android:id="@+id/keahlian"
     android:layout_width="100dp"
     android:layout_height="100dp"
     android:background="@drawable/konpetensi1"
     android:layout_marginLeft="190dp"
        android:layout_marginTop="150dp"
     />


 <Button
     android:id="@+id/fumum"
     android:layout_width="100dp"
     android:layout_height="100dp"
     android:background="@drawable/f_umum1"
     android:layout_marginLeft="30dp"
        android:layout_marginTop="290dp"
     />


 <Button
     android:id="@+id/flab"
     android:layout_width="100dp"
     android:layout_height="100dp"
     android:background="@drawable/f_lab1"
     android:layout_marginLeft="190dp"
        android:layout_marginTop="290dp"
     />
 

</RelativeLayout>

3. activity_dosen.xml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@drawable/dosen"
    android:orientation="vertical"
    tools:context=".Dosen" >


</LinearLayout>

4. activity_fumum.xml sebagai fasilitas umun

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical"
    android:background="@drawable/fumum"
    tools:context=".Fumum" >

 

</LinearLayout>

5. activity_flab.xml sebagai fasilitas lab

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical"
    android:background="@drawable/flab"
    tools:context=".Flab" >


</LinearLayout>

6. activity_keahlian.xml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical"
    android:background="@drawable/keahlian"
    tools:context=".Keahlian" >



</LinearLayout>

kemudian kita masuk pada javanya untuk pendeklarasian file xml yang telah kita buat tadi

1. MainActivity.java

   package com.titin.poligon;

import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

public class MainActivity extends Activity implements OnClickListener{
 Button menu;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        Button menu = (Button)findViewById(R.id.btn_menu);
        menu.setOnClickListener(this);
    }


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


 @Override
 public void onClick(View arg0) {
  // TODO Auto-generated method stub
  Intent m = new Intent(MainActivity. this, MenuActivity.class);
  startActivity(m);
 
 }
  
}

2.MenuActivity.java

package com.titin.poligon;


import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

public class MenuActivity extends Activity implements OnClickListener{
 Button dosen;
 Button keahlian;
 Button fumum;
 Button flab;

 @Override
 protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_menu);
 
  Button dosen = (Button)findViewById(R.id.dosen);
  Button keahlian = (Button)findViewById(R.id.keahlian);
  Button fumum = (Button)findViewById(R.id.fumum);
  Button flab = (Button)findViewById(R.id.flab);
 
  dosen.setOnClickListener(new OnClickListener() {
  
   @Override
   public void onClick(View arg0) {
    // TODO Auto-generated method stub
    Intent masuk = new Intent(MenuActivity. this, Dosen.class);
    startActivity(masuk);
   }
  });
  keahlian.setOnClickListener(new OnClickListener() {
  
   @Override
   public void onClick(View arg0) {
    // TODO Auto-generated method stub
    Intent masuk = new Intent (MenuActivity. this, Keahlian.class);
    startActivity(masuk);
   }
  });
  fumum.setOnClickListener(new OnClickListener() {
  
   @Override
   public void onClick(View arg0) {
    // TODO Auto-generated method stub
    Intent masuk = new Intent (MenuActivity. this, Fumum.class);
    startActivity(masuk);
   }
  });
  flab.setOnClickListener(new OnClickListener() {
  
   @Override
   public void onClick(View arg0) {
    // TODO Auto-generated method stub
    Intent masuk = new Intent(MenuActivity. this, Flab.class);
    startActivity(masuk);
   }
  });
 }

 @Override
 public boolean onCreateOptionsMenu(Menu menu) {
  // Inflate the menu; this adds items to the action bar if it is present.
  getMenuInflater().inflate(R.menu.menu, menu);
  return true;
 }


 @Override
 public void onClick(View arg0) {
  // TODO Auto-generated method stub
 
  Intent dosen = new Intent (this, Dosen.class);
  startActivity(dosen);
 
 }

}

3. Dosen.java

package com.titin.poligon;

import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;

public class Dosen extends Activity {

 @Override
 protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_dosen);
 }

 @Override
 public boolean onCreateOptionsMenu(Menu menu) {
  // Inflate the menu; this adds items to the action bar if it is present.
  getMenuInflater().inflate(R.menu.dosen, menu);
  return true;
 }

}

4. Flab.java

package com.titin.poligon;

import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;

public class Flab extends Activity {

 @Override
 protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_flab);
 }

 @Override
 public boolean onCreateOptionsMenu(Menu menu) {
  // Inflate the menu; this adds items to the action bar if it is present.
  getMenuInflater().inflate(R.menu.flab, menu);
  return true;
 }

}

5. Fumum.java

package com.titin.poligon;

import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;

public class Fumum extends Activity {

 @Override
 protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_fumum);
 }

 @Override
 public boolean onCreateOptionsMenu(Menu menu) {
  // Inflate the menu; this adds items to the action bar if it is present.
  getMenuInflater().inflate(R.menu.fumum, menu);
  return true;
 }

}

6. Keahlian.java

package com.titin.poligon;

import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;

public class Keahlian extends Activity {

 @Override
 protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_keahlian);
 }

 @Override
 public boolean onCreateOptionsMenu(Menu menu) {
  // Inflate the menu; this adds items to the action bar if it is present.
  getMenuInflater().inflate(R.menu.keahlian, menu);
  return true;
 }

}


jika sudah dan tidak ada yang eror maka langsung saja jalankan aplikasinya.. jika masih ada yang eror mungkin ada yang salah pada nama class nya dan jika di ranning hasilnya akan seperti ini..









Komentar

Postingan populer dari blog ini

Aplikasi Biodata Diri Menggunakan eclipse ADT

Phone Call

TEKS TO SPEACH