Advertisement
heru-kzw

Untitled

Nov 17th, 2016
207
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5.38 KB | None | 0 0
  1. package com.example.kursusandroid;
  2.  
  3. import android.app.ListActivity;
  4. import android.content.Intent;
  5. import android.os.Bundle;
  6. import android.view.View;
  7. import android.widget.AdapterView;
  8. import android.widget.AdapterView.OnItemClickListener;
  9. import android.widget.ArrayAdapter;
  10. import android.widget.ListView;
  11. import android.widget.TextView;
  12. import android.widget.Toast;
  13.  
  14. public class ListSubmenu extends ListActivity {
  15.  
  16.     int jd;
  17.     String[]arrNama_Sekolah;
  18.     String[]arrTelepon;
  19.     String[]arrWeb;
  20.     String[]arrAlamat;
  21.     int[]arrGbr;
  22.  
  23.  
  24.     @Override
  25.     public void onCreate(Bundle savedInstanceState) {
  26.         super.onCreate(savedInstanceState);
  27.  
  28.         String pil="SMA";
  29.  
  30.         Intent io = this.getIntent();
  31.  
  32.         pil=io.getStringExtra("Nama");//untuk menangkap kiriman data dari yang sebelumnya
  33.  
  34.         if(pil.equals("SMA")) {
  35.             jd = 4;
  36.             arrNama_Sekolah = new String[jd];
  37.             arrTelepon = new String[jd];
  38.             arrWeb = new String[jd];
  39.             arrAlamat = new String[jd];
  40.             arrGbr = new int[jd];
  41.  
  42.             arrTelepon[0] = "085770711576";
  43.             arrNama_Sekolah[0] = "SMA Negeri 109";
  44.             arrWeb[0] = "http://shareti.esy.es/";
  45.             arrAlamat[0] = "Jl. Gardu 7271116";
  46.             arrGbr[0]=R.drawable.sma;
  47.  
  48.             arrTelepon[1] = "085770711576";
  49.             arrNama_Sekolah[1] = "SMA Negeri 38";
  50.             arrWeb[1] = "http://herupsht.esy.es/";
  51.             arrAlamat[1] = "Jl. Raya Lenteng Agung 7270865";
  52.             arrGbr[1]=R.drawable.sma;
  53.  
  54.             arrTelepon[2] = "085770711576";
  55.             arrNama_Sekolah[2] = "SMA Negeri 97";
  56.             arrWeb[2] = "http://shareti.esy.es/";
  57.             arrAlamat[2] = "Jl. Brigif 2 7270960";
  58.             arrGbr[2]=R.drawable.sma;
  59.  
  60.             arrTelepon[3] = "085770711576";
  61.             arrNama_Sekolah[3] = "SMA Negeri 87";
  62.             arrWeb[3] = "http://heru.jakartashare.com/";
  63.             arrAlamat[3] = "Jl. Mawar II Bintaro 73881969";
  64.             arrGbr[3]=R.drawable.sma;
  65.         }
  66.  
  67.         else if(pil.equals("SMP")) {
  68.             jd = 4;
  69.             arrNama_Sekolah = new String[jd];
  70.             arrTelepon = new String[jd];
  71.             arrWeb = new String[jd];
  72.             arrAlamat = new String[jd];
  73.             arrGbr = new int[jd];
  74.  
  75.             arrTelepon[0] = "085770711576";
  76.             arrNama_Sekolah[0] = "SMP Negeri 109";
  77.             arrWeb[0] = "http://shareti.esy.es/";
  78.             arrAlamat[0] = "Jl. Gardu 7271116";
  79.             arrGbr[0]=R.drawable.smp;
  80.  
  81.             arrTelepon[1] = "085770711576";
  82.             arrNama_Sekolah[1] = "SMP Negeri 38";
  83.             arrWeb[1] = "http://herupsht.esy.es/";
  84.             arrAlamat[1] = "Jl. Raya Lenteng Agung 7270865";
  85.             arrGbr[1]=R.drawable.smp;
  86.  
  87.             arrTelepon[2] = "085770711576";
  88.             arrNama_Sekolah[2] = "SMP Negeri 97";
  89.             arrWeb[2] = "http://shareti.esy.es/";
  90.             arrAlamat[2] = "Jl. Brigif 2 7270960";
  91.             arrGbr[2]=R.drawable.smp;
  92.  
  93.             arrTelepon[3] = "085770711576";
  94.             arrNama_Sekolah[3] = "SMP Negeri 87";
  95.             arrWeb[3] = "http://heru.jakartashare.com/";
  96.             arrAlamat[3] = "Jl. Mawar II Bintaro 73881969";
  97.             arrGbr[3]=R.drawable.smp;
  98.         }
  99.  
  100.         else if(pil.equals("SD")) {
  101.             jd = 4;
  102.             arrNama_Sekolah = new String[jd];
  103.             arrTelepon = new String[jd];
  104.             arrWeb = new String[jd];
  105.             arrAlamat = new String[jd];
  106.             arrGbr = new int[jd];
  107.  
  108.             arrTelepon[0] = "085770711576";
  109.             arrNama_Sekolah[0] = "SD Negeri 109";
  110.             arrWeb[0] = "http://shareti.esy.es/";
  111.             arrAlamat[0] = "Jl. Gardu 7271116";
  112.             arrGbr[0]=R.drawable.sd;
  113.  
  114.             arrTelepon[1] = "085770711576";
  115.             arrNama_Sekolah[1] = "SD Negeri 38";
  116.             arrWeb[1] = "http://herupsht.esy.es/";
  117.             arrAlamat[1] = "Jl. Raya Lenteng Agung 7270865";
  118.             arrGbr[1]=R.drawable.sd;
  119.  
  120.             arrTelepon[2] = "085770711576";
  121.             arrNama_Sekolah[2] = "SD Negeri 97";
  122.             arrWeb[2] = "http://shareti.esy.es/";
  123.             arrAlamat[2] = "Jl. Brigif 2 7270960";
  124.             arrGbr[2]=R.drawable.sd;
  125.  
  126.             arrTelepon[3] = "085770711576";
  127.             arrNama_Sekolah[3] = "SD Negeri 87";
  128.             arrWeb[3] = "http://heru.jakartashare.com/";
  129.             arrAlamat[3] = "Jl. Mawar II Bintaro 73881969";
  130.             arrGbr[3]=R.drawable.sd;
  131.         }
  132.  
  133.  
  134.  
  135.         setListAdapter(new ArrayAdapter<String>(this, R.layout.list_sekolah,arrNama_Sekolah));
  136.         ListView listView = getListView();
  137.         listView.setTextFilterEnabled(true);
  138.  
  139.         listView.setOnItemClickListener(new OnItemClickListener() {
  140.             public void onItemClick(AdapterView<?> parent, View view,int p, long id) {
  141.  
  142.                 Intent i = new Intent(ListSubmenu.this, detailSubmenu.class);
  143.                 i.putExtra("Nama_Sekolah", arrNama_Sekolah[p]);
  144.                 i.putExtra("Web", arrWeb[p]);
  145.                 i.putExtra("Telepone", arrTelepon[p]);
  146.                 i.putExtra("Alamat", arrAlamat[p]);
  147.                 i.putExtra("gambar", arrGbr[p]);
  148.                 startActivity(i);
  149.  
  150.  
  151.                 Toast.makeText(getApplicationContext(),((TextView) view).getText(), Toast.LENGTH_SHORT).show();
  152.             }
  153.         });
  154.  
  155.     }
  156.  
  157. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement