Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.18 KB | None | 0 0
  1. package com.example.mateusz.newapplicationtest_firstlab;
  2.  
  3. import android.support.v7.app.AppCompatActivity;
  4. import android.os.Bundle;
  5. import android.widget.ArrayAdapter;
  6. import android.widget.ListAdapter;
  7. import android.widget.ListView;
  8.  
  9. import java.util.ArrayList;
  10.  
  11. public class ShowList extends AppCompatActivity {
  12.  
  13. public ArrayList<Student> students;
  14. public ListAdapter mainAdapter;
  15.  
  16. @Override
  17. protected void onCreate(Bundle savedInstanceState) {
  18. super.onCreate(savedInstanceState);
  19. setContentView(R.layout.activity_show_list);
  20.  
  21.  
  22. students = new ArrayList<>();
  23. mainAdapter = new ArrayAdapter<Student>(this, android.R.layout.simple_list_item_1, students);
  24.  
  25. Student st1 = new Student("Imie_1", "Nazwisko_1");
  26. Student st2 = new Student("Imie_2", "Nazwisko_2");
  27. Student st3 = new Student("Imie_3", "Nazwisko_3");
  28.  
  29. students.add(st1);
  30. students.add(st2);
  31. students.add(st3);
  32.  
  33. ListView listView = (ListView)findViewById(R.id.list_item);
  34. listView.setAdapter(mainAdapter);
  35. }
  36.  
  37. @Override
  38. protected void onStart() {
  39. super.onStart();
  40. }
  41.  
  42.  
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement