Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.example.kursusandroid;
- import android.app.ListActivity;
- import android.content.Intent;
- import android.os.Bundle;
- import android.view.View;
- import android.widget.AdapterView;
- import android.widget.AdapterView.OnItemClickListener;
- import android.widget.ArrayAdapter;
- import android.widget.ListView;
- import android.widget.TextView;
- import android.widget.Toast;
- public class ListSubmenu extends ListActivity {
- int jd;
- String[]arrNama_Sekolah;
- String[]arrTelepon;
- String[]arrWeb;
- String[]arrAlamat;
- int[]arrGbr;
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- String pil="SMA";
- Intent io = this.getIntent();
- pil=io.getStringExtra("Nama");//untuk menangkap kiriman data dari yang sebelumnya
- if(pil.equals("SMA")) {
- jd = 4;
- arrNama_Sekolah = new String[jd];
- arrTelepon = new String[jd];
- arrWeb = new String[jd];
- arrAlamat = new String[jd];
- arrGbr = new int[jd];
- arrTelepon[0] = "085770711576";
- arrNama_Sekolah[0] = "SMA Negeri 109";
- arrWeb[0] = "http://shareti.esy.es/";
- arrAlamat[0] = "Jl. Gardu 7271116";
- arrGbr[0]=R.drawable.sma;
- arrTelepon[1] = "085770711576";
- arrNama_Sekolah[1] = "SMA Negeri 38";
- arrWeb[1] = "http://herupsht.esy.es/";
- arrAlamat[1] = "Jl. Raya Lenteng Agung 7270865";
- arrGbr[1]=R.drawable.sma;
- arrTelepon[2] = "085770711576";
- arrNama_Sekolah[2] = "SMA Negeri 97";
- arrWeb[2] = "http://shareti.esy.es/";
- arrAlamat[2] = "Jl. Brigif 2 7270960";
- arrGbr[2]=R.drawable.sma;
- arrTelepon[3] = "085770711576";
- arrNama_Sekolah[3] = "SMA Negeri 87";
- arrWeb[3] = "http://heru.jakartashare.com/";
- arrAlamat[3] = "Jl. Mawar II Bintaro 73881969";
- arrGbr[3]=R.drawable.sma;
- }
- else if(pil.equals("SMP")) {
- jd = 4;
- arrNama_Sekolah = new String[jd];
- arrTelepon = new String[jd];
- arrWeb = new String[jd];
- arrAlamat = new String[jd];
- arrGbr = new int[jd];
- arrTelepon[0] = "085770711576";
- arrNama_Sekolah[0] = "SMP Negeri 109";
- arrWeb[0] = "http://shareti.esy.es/";
- arrAlamat[0] = "Jl. Gardu 7271116";
- arrGbr[0]=R.drawable.smp;
- arrTelepon[1] = "085770711576";
- arrNama_Sekolah[1] = "SMP Negeri 38";
- arrWeb[1] = "http://herupsht.esy.es/";
- arrAlamat[1] = "Jl. Raya Lenteng Agung 7270865";
- arrGbr[1]=R.drawable.smp;
- arrTelepon[2] = "085770711576";
- arrNama_Sekolah[2] = "SMP Negeri 97";
- arrWeb[2] = "http://shareti.esy.es/";
- arrAlamat[2] = "Jl. Brigif 2 7270960";
- arrGbr[2]=R.drawable.smp;
- arrTelepon[3] = "085770711576";
- arrNama_Sekolah[3] = "SMP Negeri 87";
- arrWeb[3] = "http://heru.jakartashare.com/";
- arrAlamat[3] = "Jl. Mawar II Bintaro 73881969";
- arrGbr[3]=R.drawable.smp;
- }
- else if(pil.equals("SD")) {
- jd = 4;
- arrNama_Sekolah = new String[jd];
- arrTelepon = new String[jd];
- arrWeb = new String[jd];
- arrAlamat = new String[jd];
- arrGbr = new int[jd];
- arrTelepon[0] = "085770711576";
- arrNama_Sekolah[0] = "SD Negeri 109";
- arrWeb[0] = "http://shareti.esy.es/";
- arrAlamat[0] = "Jl. Gardu 7271116";
- arrGbr[0]=R.drawable.sd;
- arrTelepon[1] = "085770711576";
- arrNama_Sekolah[1] = "SD Negeri 38";
- arrWeb[1] = "http://herupsht.esy.es/";
- arrAlamat[1] = "Jl. Raya Lenteng Agung 7270865";
- arrGbr[1]=R.drawable.sd;
- arrTelepon[2] = "085770711576";
- arrNama_Sekolah[2] = "SD Negeri 97";
- arrWeb[2] = "http://shareti.esy.es/";
- arrAlamat[2] = "Jl. Brigif 2 7270960";
- arrGbr[2]=R.drawable.sd;
- arrTelepon[3] = "085770711576";
- arrNama_Sekolah[3] = "SD Negeri 87";
- arrWeb[3] = "http://heru.jakartashare.com/";
- arrAlamat[3] = "Jl. Mawar II Bintaro 73881969";
- arrGbr[3]=R.drawable.sd;
- }
- setListAdapter(new ArrayAdapter<String>(this, R.layout.list_sekolah,arrNama_Sekolah));
- ListView listView = getListView();
- listView.setTextFilterEnabled(true);
- listView.setOnItemClickListener(new OnItemClickListener() {
- public void onItemClick(AdapterView<?> parent, View view,int p, long id) {
- Intent i = new Intent(ListSubmenu.this, detailSubmenu.class);
- i.putExtra("Nama_Sekolah", arrNama_Sekolah[p]);
- i.putExtra("Web", arrWeb[p]);
- i.putExtra("Telepone", arrTelepon[p]);
- i.putExtra("Alamat", arrAlamat[p]);
- i.putExtra("gambar", arrGbr[p]);
- startActivity(i);
- Toast.makeText(getApplicationContext(),((TextView) view).getText(), Toast.LENGTH_SHORT).show();
- }
- });
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement