Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @Override
- public View onCreateView(LayoutInflater inflater, ViewGroup container,
- Bundle savedInstanceState) {
- // Inflate the layout for this fragment
- setHasOptionsMenu(true);
- View view = inflater.inflate(R.layout.fragment_residuos, container, false);
- final GridView gridview = view.findViewById(R.id.grid_elements);
- adapter = new ResiduosAdapter(this.activity);
- gridview.setAdapter(adapter);
- // creo un objeto listener
- AdapterView.OnItemClickListener listener = new AdapterView.OnItemClickListener() {
- @Override
- public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
- Toast.makeText(getContext().getApplicationContext(),
- "Click ListItem Number " + i, Toast.LENGTH_LONG)
- .show();
- }
- };
- // asigno el objeto listener al gridview
- gridview.setOnItemClickListener(listener);
- return view;
- }
- <RelativeLayout xmlns:p1="http://schemas.android.com/apk/res/android"
- p1:minWidth="25px"
- p1:minHeight="25px"
- p1:layout_width="match_parent"
- p1:layout_height="match_parent"
- p1:id="@+id/relativeLayout1"
- p1:padding="10dp">
- <GridView
- p1:id="@+id/grid_elements"
- p1:layout_width="match_parent"
- p1:layout_height="match_parent"
- p1:choiceMode="multipleChoice"
- p1:clickable="false"
- p1:drawSelectorOnTop="true"
- p1:horizontalSpacing="2dp"
- p1:minHeight="25px"
- p1:minWidth="25px"
- p1:numColumns="3"
- p1:verticalSpacing="2dp" />
- </RelativeLayout>
- <?xml version="1.0" encoding="utf-8"?>
- <RelativeLayout xmlns:p1="http://schemas.android.com/apk/res/android"
- xmlns:tools="http://schemas.android.com/tools"
- p1:id="@+id/relativeLayout1"
- p1:layout_width="match_parent"
- p1:layout_height="match_parent"
- p1:background="@color/primary_material_light"
- p1:focusable="false"
- p1:focusableInTouchMode="false"
- p1:minHeight="25px"
- p1:minWidth="25px">
- <ImageView
- p1:id="@+id/elements_img"
- p1:layout_width="match_parent"
- p1:layout_height="match_parent"
- p1:layout_marginLeft="8dp"
- p1:layout_marginTop="8dp"
- p1:focusable="false"
- p1:focusableInTouchMode="false"
- p1:src="@drawable/envases_plasticos" />
- <TextView
- p1:id="@+id/elements_name"
- p1:layout_width="wrap_content"
- p1:layout_height="wrap_content"
- p1:layout_below="@+id/elements_img"
- p1:layout_marginLeft="10dp"
- p1:layout_marginTop="5dp"
- p1:focusable="false"
- p1:focusableInTouchMode="false"
- p1:text=" "
- p1:textColor="@color/primary_dark_material_dark"
- p1:textSize="@dimen/abc_edit_text_inset_top_material" />
- <CheckBox
- p1:id="@+id/elements_check"
- p1:layout_width="wrap_content"
- p1:layout_height="wrap_content"
- p1:layout_alignRight="@id/elements_img"
- p1:focusable="false"
- p1:focusableInTouchMode="false" />
- </RelativeLayout>
Add Comment
Please, Sign In to add comment