Advertisement
obernardovieira

[Android] Add values to ListView

May 16th, 2014
316
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.68 KB | None | 0 0
  1. package com.example.yournameapp.app;
  2.  
  3. import android.app.Activity;
  4. import android.os.Bundle;
  5. import android.widget.ArrayAdapter;
  6. import android.widget.ListView;
  7.  
  8. public class MainActivity extends Activity {
  9.  
  10.     @Override
  11.     protected void onCreate(Bundle savedInstanceState) {
  12.         super.onCreate(savedInstanceState);
  13.         setContentView(R.layout.main_activity);
  14.  
  15.         String[] listItems = {"item 1", "item 2 ", "list", "android", "item 3", "foobar", "bar", "bye", "me", "you", "us", "good" };
  16.  
  17.         ListView lv = (ListView) findViewById(R.id.your_listview_name);
  18.         lv.setAdapter(new ArrayAdapter(this,  android.R.layout.simple_list_item_1, listItems));
  19.     }
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement