Guest User

Untitled

a guest
Oct 19th, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.29 KB | None | 0 0
  1. //***IMAGE ADAPTER CLASS***
  2. public class ImageAdapter extends BaseAdapter
  3. {
  4. Context MyContext;
  5.  
  6. public ImageAdapter(Context _MyContext)
  7. {
  8. MyContext = _MyContext;
  9. }
  10.  
  11. @Override
  12. public int getCount()
  13. {
  14. return currentTitlesList.size();
  15. }
  16.  
  17. @Override
  18. public View getView(int position, View convertView, ViewGroup parent)
  19. {
  20. View MyView;
  21.  
  22. if ( convertView == null )
  23. {
  24. LayoutInflater li = getLayoutInflater();
  25. MyView = li.inflate(R.layout.grid_item, null);
  26. }
  27. else
  28. {
  29. MyView = convertView;
  30. }
  31.  
  32. try
  33. {
  34. iv = (ImageView) MyView.findViewById(R.id.grid_item_image);
  35. iv.setImageBitmap(currentPhotosList.get(position)); //set tile image
  36.  
  37. gridText = (TextView)MyView.findViewById(R.id.grid_item_text);
  38. gridText.setText(" " + currentTitlesList.get(position) + " "); //set tile text
  39.  
  40. }
  41. catch (Exception e)
  42. {
  43. Toast.makeText(getApplicationContext(), R.string.tileObjectError, Toast.LENGTH_LONG).show();
  44. }
  45.  
  46. return MyView;
  47. }
  48.  
  49.  
  50. @Override
  51. public Object getItem(int arg0)
  52. {
  53. // TODO Auto-generated method stub
  54. return null;
  55. }
  56.  
  57. @Override
  58. public long getItemId(int arg0)
  59. {
  60. // TODO Auto-generated method stub
  61. return 0;
  62. }
  63. }
Add Comment
Please, Sign In to add comment