Main Activity.java
package com.example.empatactivity1project;
import android.os.Bundle;
import android.app.ListActivity;
import android.content.Intent;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ListView;
public class MainActivity extends ListActivity {
String[]prodi={
"Activity Akuntansi","Activity Teknik Informatika","Activity Refrigrasi"
};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
String[] jurusan = null;
setListAdapter(new ArrayAdapter <String>(this,android.R.layout.simple_list_item_1,jurusan));
}
public void onListItemClick(ListView parent,View v,int urutan,long id){
Object detail=this.getListAdapter().getItem(urutan);
String tampil=detail.toString();
Intent i=null;
if(tampil=="Activity Akuntansi")
{
i=new Intent(MainActivity.this,ActivityAkuntansi.class);
startActivity(i);
}
else if(tampil=="Activity Teknik Informatika")
{
i=new Intent(MainActivity.this,ActivityTeknikInformatika.class);
startActivity(i);
}
else if(tampil=="Activity Refrigrasi")
{
i=new Intent(MainActivity.this,ActivityRefrigrasi.class);
startActivity(i);
}
}
}
ActivityTeknikInformatika.Java
package com.example.empatactivity1project;
import android.os.Bundle;
import android.app.ListActivity;
import android.content.Intent;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.Toast;
public class ActivityTeknikInformatika extends ListActivity {
String[]prodi={"Activity Reza",
"Activity Rizal",
"Activity Tiwala",
"Activity Andika",
"Activity DLL",
"<<Kembali"};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_teknik_informatika);
setListAdapter(new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1,prodi));
}
public void onListItemClick(ListView parent,View v,int urutan,long id){
Object detail= this.getListAdapter().getItem(urutan);
String tampil= detail.toString();
Intent i=null;
if(tampil=="<<Kembali")
{
i=new Intent (ActivityTeknikInformatika.this, MainActivity.class);
startActivity(i);
}
else{
Toast.makeText(this,"Anda Memilih: "+tampil,Toast.LENGTH_SHORT).show();
}
}
}
ActivityAkuntansi.Java
package com.example.empatactivity1project;
import android.os.Bundle;
import android.app.ListActivity;
import android.content.Intent;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.Toast;
public class ActivityAkuntansi extends ListActivity {
String[]prodi={"Activity Sandi",
"Activity Aulia",
"Activity Kholik",
"Activity Joni",
"Activity Putri",
"Activity Putra",
"<<Kembali"};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_activity_akuntansi);
setListAdapter(new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1,prodi));
}
public void onListItemClick(ListView parent,View v,int urutan,long id){
Object detail=this.getListAdapter().getItem(urutan);
String tampil= detail.toString();
Intent i=null;
if(tampil=="<<Kembali")
{
i=new Intent (ActivityAkuntansi.this, MainActivity.class);
startActivity(i);
}
else{
Toast.makeText(this,"Anda Memilih: "+tampil,Toast.LENGTH_SHORT).show();
}
}
}
ActivityRefrigrasi.java
package com.example.empatactivity1project;
import android.app.ListActivity;
import android.os.Bundle;
import android.content.Intent;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.Toast;
public class ActivityRefrigrasi extends ListActivity {
String[]prodi={"Activity Hendri",
"Activity Joko",
"Activity Fahru",
"Activity Apri",
"Activity Susan","<<Kembali"};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_refrigrasi);
setListAdapter(new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1,prodi));
}
public void onListItemClick(ListView parent,View v,int urutan,long id){
Object detail=this.getListAdapter().getItem(urutan);
String tampil=detail.toString();
Intent i=null;
if(tampil=="<<Kembali")
{
i=new Intent(ActivityRefrigrasi.this,MainActivity.class);
startActivity(i);
}
else
{
Toast.makeText(this,"Anda memilih:"+tampil,Toast.LENGTH_SHORT).show();
}
}
}
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ListView
android:id="@android:id/list"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:drawSelectorOnTop="false"
/>
</LinearLayout>
activity_teknik_informatika.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ListView
android:id="@android:id/list"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:drawSelectorOnTop="false"
/>
</LinearLayout>
activity_activity_akuntansi.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ListView
android:id="@android:id/list"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:drawSelectorOnTop="false"
/>
</LinearLayout>
activity_refrigrasi.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ListView
android:id="@android:id/list"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:drawSelectorOnTop="false"
/>
</LinearLayout>
AndroidManifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.empatactivity1project"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.example.empatactivity1project.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.example.empatactivity1project.ActivityAkuntansi"
android:label="@string/title_activity_activity_akuntansi" >
</activity>
<activity
android:name="com.example.empatactivity1project.ActivityTeknikInformatika"
android:label="@string/title_activity_activity_teknik_informatika" >
</activity>
<activity
android:name="com.example.empatactivity1project.ActivityRefrigrasi"
android:label="@string/title_activity_activity_refrigrasi" >
</activity>
</application>
</manifest>
Semoga bermanfaat :)
Salam ...
filenya dong di upload, biar lbih bermanfa'at :-D
BalasHapus