Guest User

Untitled

a guest
Jul 12th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.01 KB | None | 0 0
  1. @Override
  2. public View onCreateView(LayoutInflater inflater, ViewGroup container,
  3. Bundle savedInstanceState) {
  4. // Inflate the layout for this fragment
  5. setHasOptionsMenu(true);
  6. View view = inflater.inflate(R.layout.fragment_residuos, container, false);
  7. final GridView gridview = view.findViewById(R.id.grid_elements);
  8. adapter = new ResiduosAdapter(this.activity);
  9. gridview.setAdapter(adapter);
  10. // creo un objeto listener
  11. AdapterView.OnItemClickListener listener = new AdapterView.OnItemClickListener() {
  12.  
  13. @Override
  14. public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
  15. Toast.makeText(getContext().getApplicationContext(),
  16. "Click ListItem Number " + i, Toast.LENGTH_LONG)
  17. .show();
  18. }
  19. };
  20. // asigno el objeto listener al gridview
  21. gridview.setOnItemClickListener(listener);
  22. return view;
  23. }
  24.  
  25. <RelativeLayout xmlns:p1="http://schemas.android.com/apk/res/android"
  26. p1:minWidth="25px"
  27. p1:minHeight="25px"
  28. p1:layout_width="match_parent"
  29. p1:layout_height="match_parent"
  30. p1:id="@+id/relativeLayout1"
  31. p1:padding="10dp">
  32.  
  33. <GridView
  34. p1:id="@+id/grid_elements"
  35. p1:layout_width="match_parent"
  36. p1:layout_height="match_parent"
  37. p1:choiceMode="multipleChoice"
  38. p1:clickable="false"
  39. p1:drawSelectorOnTop="true"
  40. p1:horizontalSpacing="2dp"
  41. p1:minHeight="25px"
  42. p1:minWidth="25px"
  43. p1:numColumns="3"
  44. p1:verticalSpacing="2dp" />
  45. </RelativeLayout>
  46.  
  47. <?xml version="1.0" encoding="utf-8"?>
  48. <RelativeLayout xmlns:p1="http://schemas.android.com/apk/res/android"
  49. xmlns:tools="http://schemas.android.com/tools"
  50. p1:id="@+id/relativeLayout1"
  51. p1:layout_width="match_parent"
  52. p1:layout_height="match_parent"
  53. p1:background="@color/primary_material_light"
  54. p1:focusable="false"
  55. p1:focusableInTouchMode="false"
  56. p1:minHeight="25px"
  57. p1:minWidth="25px">
  58.  
  59. <ImageView
  60. p1:id="@+id/elements_img"
  61. p1:layout_width="match_parent"
  62. p1:layout_height="match_parent"
  63. p1:layout_marginLeft="8dp"
  64. p1:layout_marginTop="8dp"
  65. p1:focusable="false"
  66. p1:focusableInTouchMode="false"
  67. p1:src="@drawable/envases_plasticos" />
  68.  
  69. <TextView
  70. p1:id="@+id/elements_name"
  71. p1:layout_width="wrap_content"
  72. p1:layout_height="wrap_content"
  73. p1:layout_below="@+id/elements_img"
  74. p1:layout_marginLeft="10dp"
  75. p1:layout_marginTop="5dp"
  76. p1:focusable="false"
  77. p1:focusableInTouchMode="false"
  78. p1:text=" "
  79. p1:textColor="@color/primary_dark_material_dark"
  80. p1:textSize="@dimen/abc_edit_text_inset_top_material" />
  81.  
  82. <CheckBox
  83. p1:id="@+id/elements_check"
  84. p1:layout_width="wrap_content"
  85. p1:layout_height="wrap_content"
  86. p1:layout_alignRight="@id/elements_img"
  87. p1:focusable="false"
  88. p1:focusableInTouchMode="false" />
  89. </RelativeLayout>
Add Comment
Please, Sign In to add comment