Advertisement
Guest User

Untitled

a guest
Apr 20th, 2014
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.08 KB | None | 0 0
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <GridView xmlns:android="http://schemas.android.com/apk/res/android"
  3. android:id="@+id/gridview"
  4. android:layout_width="fill_parent"
  5. android:layout_height="fill_parent"
  6. android:columnWidth="400dp"
  7. android:numColumns="4"
  8. android:verticalSpacing="10dp"
  9. android:horizontalSpacing="10dp"
  10. android:stretchMode="columnWidth"
  11. android:gravity="center"
  12. android:background="#444444" />
  13.  
  14. <?xml version="1.0" encoding="utf-8"?>
  15. <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  16. android:orientation="vertical"
  17. android:layout_width="match_parent"
  18. android:layout_height="match_parent">
  19. <ImageView
  20. android:id="@+id/image"
  21. android:layout_height="match_parent"
  22. android:layout_width="match_parent"
  23. android:layout_centerInParent="true"
  24. android:scaleType="centerCrop" />
  25. <LinearLayout
  26. android:layout_height="wrap_content"
  27. android:layout_width="match_parent"
  28. android:background="#88FFFFFF"
  29. android:gravity="center_horizontal">
  30. <TextView
  31. android:id="@+id/name"
  32. android:layout_height="wrap_content"
  33. android:layout_width="wrap_content"
  34. android:textStyle="bold"
  35. android:textSize="25dp"
  36. android:textColor="#000000" />
  37. </LinearLayout>
  38. </RelativeLayout>
  39.  
  40. // create a new ImageView for each item referenced by the Adapter
  41. public override View GetView (int position, View convertView, ViewGroup parent)
  42. {
  43. View grid;
  44.  
  45. if (convertView == null) {
  46.  
  47. LayoutInflater inflater = (LayoutInflater)context
  48. .GetSystemService (Context.LayoutInflaterService);
  49. grid = inflater.Inflate (Resource.Layout.gridItem, null);
  50. }
  51. else {
  52.  
  53. grid = (View) convertView;
  54. }
  55.  
  56. ImageView image = (ImageView)grid.FindViewById (Resource.Id.image);
  57. TextView name= (TextView)grid.FindViewById (Resource.Id.name);
  58.  
  59. image.SetImageBitmap(DecodeSampledBitmap ("Image Path", Width, Height));
  60. name.Text = "Text You Want";
  61.  
  62. return grid;
  63. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement