Guest User

Untitled

a guest
Nov 20th, 2017
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.71 KB | None | 0 0
  1. public class DemoList extends AppCompatActivity {
  2. private ListView list_demo;
  3. private ArrayList<String> numberlist;
  4.  
  5. @Override
  6. protected void onCreate(Bundle savedInstanceState) {
  7. super.onCreate(savedInstanceState);
  8. setContentView(R.layout.activity_demo_list);
  9. list_demo = (ListView) findViewById(R.id.list_demo);
  10.  
  11.  
  12. numberlist = new ArrayList<String>();
  13. getNumberList();
  14. int str1 = Integer.parseInt(Collections.min(numberlist));
  15. String str = Collections.max(numberlist).toString();
  16. //getMax(numberlist, str1);
  17.  
  18. printInOrder(numberlist);
  19. Integer[] stringArray = numberlist.toArray(new Integer[0]);
  20. getMax(stringArray);
  21. ArrayAdapter<String> arrayAdapter =
  22. new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, numberlist);
  23. // Set The Adapter
  24. list_demo.setAdapter(arrayAdapter);
  25. }
  26.  
  27.  
  28. void getNumberList() {
  29. numberlist.add("1");
  30. numberlist.add("2");
  31. numberlist.add("7");
  32. numberlist.add("10");
  33. numberlist.add("15");
  34. numberlist.add("6");
  35. numberlist.add("3");
  36. numberlist.add("0");
  37. numberlist.add("25");
  38. numberlist.add("99");
  39. numberlist.add("70");
  40. numberlist.add("65");
  41. numberlist.add("1000");
  42.  
  43.  
  44. }
  45.  
  46. public static void printInOrder(ArrayList data) {
  47.  
  48. }
  49.  
  50. public static int getMax(Integer[] inputArray) {
  51. int maxValue = inputArray[0];
  52. for (int i = 1; i < inputArray.length; i++) {
  53. if (inputArray[i] > maxValue) {
  54. maxValue = inputArray[i];
  55. }
  56. }
  57. return maxValue;
  58. }
  59.  
  60.  
  61. }
  62.  
  63. Collections.max(yourArraylist);
Add Comment
Please, Sign In to add comment