Kamis, 08 Juni 2017

Membuat Aplikasi Leaflet Berbasis Android

Assalamualaiqum
Siang ini kita akan membahas tentang cara membuat leaflet sederhana berbasis android. Disini kita hanya menggunakan view – view saja atau hanya berpindah ke layout lainnya.
Ok langsung saja simak langkah – langkah membuatnya:
  1. Buat project baru dengan nama Leaflet.
  2. Buat file xml dan java
  1. Source code file activity_awal.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:background="@drawable/awal"
   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=".AwalActivity" >
   <Button
       android:id="@+id/button1"
       android:layout_width="wrap_content"
       android:layout_height="wrap_content"
       android:layout_alignParentBottom="true"
       android:layout_alignParentLeft="true"
       android:layout_marginBottom="191dp"
       android:background="@drawable/menu" />
</RelativeLayout>
Tampilannya menjadi:
  1. Isikan source code pada file activity_menu.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:background="@drawable/menu1"
   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=".MenuActivity" >
   <Button
       android:id="@+id/dosen"
       android:layout_width="100dp"
       android:layout_height="100dp"
       android:background="@drawable/dosen"
       android:layout_marginLeft="30dp"
       android:layout_marginTop="150dp"
       />   
<Button
   android:id="@+id/ahli"
   android:layout_width="100dp"
   android:layout_height="100dp"
   android:background="@drawable/ahli"
   android:layout_marginLeft="190dp"
       android:layout_marginTop="150dp"
   />
<Button
   android:id="@+id/prestasi"
   android:layout_width="100dp"
   android:layout_height="100dp"
   android:background="@drawable/prestasi"
   android:layout_marginLeft="30dp"
       android:layout_marginTop="290dp"
   />
<Button
   android:id="@+id/lab"
   android:layout_width="100dp"
   android:layout_height="100dp"
   android:background="@drawable/lab"
   android:layout_marginLeft="190dp"
       android:layout_marginTop="290dp"
   />
</RelativeLayout>

Hasilnya akan menjadi seperti berikut:

  1. Source code file activity_dosen.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:background="@drawable/dosen1"
   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=".DosenActivity" >
</RelativeLayout>
Hasilnya:
  1. Source code file activity_ahli.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:background="@drawable/ahli1"
   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=".AhliActivity" >
</RelativeLayout>
Hasilnya:
  1. Source code file activity_lab.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:background="@drawable/lab1"
   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=".LabActivity" >
</RelativeLayout>
Hasilnya:
  1. File activity_prestasi.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:background="@drawable/prestasi1"
   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=".PrestasiActivity" >
</RelativeLayout>
Hasilnya:
  1. Selanjutnya source code file AwalActivity.java
package com.example.leafletit;
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 AwalActivity extends Activity implements OnClickListener {
Button Menu;
   @Override
   protected void onCreate(Bundle savedInstanceState) {
       super.onCreate(savedInstanceState);
       setContentView(R.layout.activity_awal);
       Button Menu = (Button) findViewById(R.id.button1);
       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.awal, menu);
       return true;
   }
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
Intent Menu = new Intent (AwalActivity. this, MenuActivity.class);
startActivity(Menu);
}
}
  1. File MenuActivity.java
package com.example.leafletit;

import com.example.leafletit.DosenActivity;
import com.example.leafletit.LabActivity;
import com.example.leafletit.PrestasiActivity;
import com.example.leafletit.AhliActivity;
import com.example.leafletit.MenuActivity;
import com.example.leafletit.R;
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 ahli;
Button prestasi;
Button lab;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_menu);
Button dosen = (Button)findViewById(R.id.dosen);
Button ahli = (Button)findViewById(R.id.ahli);
Button prestasi = (Button)findViewById(R.id.prestasi);
Button lab = (Button)findViewById(R.id.lab);
dosen.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
Intent masuk = new Intent(MenuActivity. this, DosenActivity.class);
startActivity(masuk);
}
});
ahli.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
Intent masuk = new Intent (MenuActivity. this, AhliActivity.class);
startActivity(masuk);
}
});
prestasi.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
Intent masuk = new Intent (MenuActivity. this, PrestasiActivity.class);
startActivity(masuk);
}
});
lab.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
Intent masuk = new Intent(MenuActivity. this, LabActivity.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
}
}
  1. File AhliActivity.java
package com.example.leafletit;

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

public class AhliActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_ahli);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.ahli, menu);
return true;
}
}

  1. File DosenActivity.java
package com.example.leafletit;

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

public class DosenActivity 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;
}
}

  1. File LabActivity.java
package com.example.leafletit;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;

public class LabActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_lab);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.lab, menu);
return true;
}
}


  1. File PrestasiActivity.java
package com.example.leafletit;

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

public class PrestasiActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_prestasi);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.prestasi, menu);
return true;
}
}


  1. Terakhir jalankan program di emulator atau smartphone anda.

Semoga Bermanfaat

Related Posts:

  • Membuat Table Database Assalamu’alaiqum Wr. Wb. Jumpa lagi dengan saya, tentunya saya akan berbagi pengetahuan dan kali ini saya akan memposting tentang cara membuat table database. Ok langsung saja kita masuk pada langkah – langkahnya ☺ Buat d… Read More
  • Mengganti Background Menggunakan Channels, Paths & Levels Assalamu’alaiqum Dipostingan kali ini kita akan membahas tentang cara mengganti background menggunakan PATHS dan CHANNELS. Ok gak usah banyak basa – basi lagi, langsung saja kita masuk pada langkah – langkahnya. Buka foto… Read More
  • Membuat Tatto Pada Bagian Tubuh Assalamu’alaiqum Wr. Wb. Hello, saya balik lagi nih ☺ dan kali ini saya akan berbagi ilmu tentang cara menambahkan tatto pada bagian tubuh kita. Dari pada pake tatto beneran terus kena omel mending manipulasi foto aja :D &n… Read More
  • Membuat Undangan Wisuda Assalamu’alaiqum Hari ini saya akan kembali memposting tentang cara membuat undangan, tapi kali ini saya akan membuat undangan wisuda. OK langsung saja check it out ☺ BAGIAN LUAR Jalankan aplikasi photoshop. Buat lemb… Read More
  • Membuat Database Melalui CMD Assalamu’alaiqum Wr. Wb. Hari ini saya akan posting tentang cara membuat database pada Xampp. Ok langsung saja kita masuk pada langkah – langkahnya ☺ Buka aplikasi Xampp dan aktifkan paket Apache dan Mysql, seperti pada… Read More

0 komentar:

Posting Komentar

Copyright © 2025 Sharing Pengetahuan | Powered by Blogger