Advertisement
Guest User

Untitled

a guest
Mar 28th, 2017
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  1. public void updatePosts(){
  2. new Thread(){
  3. public void run(){
  4. posts.addAll(pholder.fetchPosts());
  5. System.out.println("size of posts is " + posts.size());
  6.  
  7. // UI elements should be accessed only in
  8. // the primary thread, so we must use the
  9. // handler here.
  10.  
  11. }
  12. }.start();
  13. }
  14.  
  15. @Override
  16. protected void onCreate(Bundle savedInstanceState) {
  17. super.onCreate(savedInstanceState);
  18. setContentView(R.layout.activity_main);
  19. updatePosts();
  20. Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
  21. setSupportActionBar(toolbar);
  22.  
  23. GridView gridview = (GridView) findViewById(R.id.gridview);
  24. gridview.setAdapter(new ImageAdapter(this, posts));
  25.  
  26. gridview.setOnItemClickListener(new AdapterView.OnItemClickListener() {
  27. public void onItemClick(AdapterView<?> parent, View v,
  28. int position, long id) {
  29. Toast.makeText(MainActivity.this, "" + position,
  30. Toast.LENGTH_SHORT).show();
  31. }
  32. });
  33.  
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement