Advertisement
euis_kusesa

MainActivity.java

Dec 24th, 2018
378
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.25 KB | None | 0 0
  1. package com.example.laptoprpl.listview;
  2.  
  3. import android.graphics.Color;
  4. import android.os.Bundle;
  5. import android.support.v7.app.AppCompatActivity;
  6. import android.view.View;
  7. import android.widget.AdapterView;
  8. import android.widget.ArrayAdapter;
  9. import android.widget.ListView;
  10. import android.widget.Toast;
  11.  
  12.  
  13. public class ListStatis extends AppCompatActivity {
  14.  
  15.     private ListView lvItem;
  16.     private String[] ceritarakyat = new String[]{"Mawar", "Melati", "Thulip", "Lili", "Anggrek", "Kamboja", "Shoka", "Cempaka", "Sepatu"};
  17.     //mendeklarasikan listview var dan menginisialasi array tipe data string
  18.     //Step 1
  19.  
  20.  
  21.  
  22.     @Override
  23.     protected void onCreate(Bundle savedInstanceState) {
  24.         super.onCreate(savedInstanceState);
  25.         setContentView(R.layout.activity_list_statis);
  26.  
  27.         getSupportActionBar().setTitle("Nama nama Bunga"); //tampil title
  28.  
  29.  
  30.         lvItem = (ListView) findViewById(R.id.list_view);
  31.         ArrayAdapter<String> adapter = new ArrayAdapter<String>(ListStatis.this, android.R.layout.simple_list_item_1, android.R.id.text1, ceritarakyat);
  32.     /*
  33.     Step 2
  34.     Membinding atau memformat data
  35.      */
  36.  
  37.         lvItem.setAdapter(adapter);
  38.         //menset data di dalam listview
  39.  
  40.  
  41.  
  42.             }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement