Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.example.laptoprpl.listview;
- import android.graphics.Color;
- import android.os.Bundle;
- import android.support.v7.app.AppCompatActivity;
- import android.view.View;
- import android.widget.AdapterView;
- import android.widget.ArrayAdapter;
- import android.widget.ListView;
- import android.widget.Toast;
- public class ListStatis extends AppCompatActivity {
- private ListView lvItem;
- private String[] ceritarakyat = new String[]{"Mawar", "Melati", "Thulip", "Lili", "Anggrek", "Kamboja", "Shoka", "Cempaka", "Sepatu"};
- //mendeklarasikan listview var dan menginisialasi array tipe data string
- //Step 1
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_list_statis);
- getSupportActionBar().setTitle("Nama nama Bunga"); //tampil title
- lvItem = (ListView) findViewById(R.id.list_view);
- ArrayAdapter<String> adapter = new ArrayAdapter<String>(ListStatis.this, android.R.layout.simple_list_item_1, android.R.id.text1, ceritarakyat);
- /*
- Step 2
- Membinding atau memformat data
- */
- lvItem.setAdapter(adapter);
- //menset data di dalam listview
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement