Assalamualikum Wr. Wb
Hay guys kali ini saya akan memberikan tutorial cara membuat browsur menggunakan android studio.ok langsung saja simak tiap stepnya di bawah ini...
1. Buka aplikasi ADT atau android
studio
2. Buat Project baru
3. source code untu
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>
4. Source
code Actifity_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>
5. source code untuk actiity_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>
6. 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>
7. 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>
8. 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>
9. 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);
            } 
}
10. 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
            }
}
11.       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;
            }
}
12.       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;
            }
}
13.       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;
            }
}
14.       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;
            }
}
15. Kemudian Run Project
 
0 Komentar