Advertisement
Guest User

Untitled

a guest
Apr 21st, 2011
2,050
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.43 KB | None | 0 0
  1.  
  2.  
  3. // myList.java
  4. package com.test.listview;
  5. import android.app.ListActivity;
  6. import android.os.Bundle;
  7. import android.view.View;
  8. import android.widget.ArrayAdapter;
  9. import android.widget.ListView;
  10.  
  11. public class myList extends ListActivity
  12. {
  13. /** Called when the activity is first created. */
  14. public void onCreate(Bundle icicle)
  15. {
  16. super.onCreate(icicle);
  17. // Create an array of Strings, that will be put to our ListActivity
  18.  
  19. String[] names = new String[] { "Linux", "Windows7", "Eclipse", "Suse",
  20. "Ubuntu", "Solaris", "Android", "iPhone", "Linux", "Windows7",
  21. "Eclipse", "Suse", "Ubuntu", "Solaris", "Android", "iPhone" };
  22. setContentView (R.layout.main);
  23. ListView listView = getListView();
  24. ArrayAdapter a = new ArrayAdapter <String>(this, android.R.layout.simple_list_item_single_choice, names);
  25. setListAdapter(a);
  26.  
  27. }
  28. }
  29.  
  30.  
  31. // strings.xml
  32. <?xml version="1.0" encoding="utf-8"?>
  33. <resources>
  34. <string name="hello">Hello World, myList!</string>
  35. <string name="app_name">listview</string>
  36. <string-array name="default_sorts">
  37. <item>foo</item>
  38. <item>asdf</item>
  39. <item>qwer</item>
  40. <item>346346</item>
  41. <item>hjkg</item>
  42. <item>asdfasdfasd</item>
  43. <item>vbncvnb</item>
  44. <item>zxc</item>
  45. <item>hjkk</item>
  46. <item>tutrurty</item>
  47. </string-array>
  48. <string name="main_empty_list">foo</string>
  49. </resources>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement