I created a gridView. Now how do I call an input from the gridview icons?

Asked

Viewed 51 times

0

Follow the code of gridview. It is in this same Activity that I want to call the actions of the grid.

//Grid VIew...set grid view item
Bitmap homeIcon = BitmapFactory.decodeResource(this.getResources(), R.drawable.teste_cor);
Bitmap userIcon1 = BitmapFactory.decodeResource(this.getResources(), R.drawable.teste_fest);
Bitmap userIcon2 = BitmapFactory.decodeResource(this.getResources(), R.drawable.teste_paris);
Bitmap userIcon3 = BitmapFactory.decodeResource(this.getResources(), R.drawable.teste_news);
Bitmap userIcon4 = BitmapFactory.decodeResource(this.getResources(), R.drawable.teste_media);
Bitmap userIcon5 = BitmapFactory.decodeResource(this.getResources(), R.drawable.local_gar);

gridArray.add(new Item(homeIcon,"menu1"));
gridArray.add(new Item(userIcon1,"menu2"));
gridArray.add(new Item(userIcon2,"menu3"));
gridArray.add(new Item(userIcon3,"menu4"));
gridArray.add(new Item(userIcon4,"menu5"));
gridArray.add(new Item(userIcon5,"menu6"));


gridView = (GridView) findViewById(R.id.gridView);

customGridAdapter = new CustomGridViewAdapter(this, R.layout.row_grid, gridArray);
gridView.setAdapter(customGridAdapter);

1 answer

1


I usually do it this way:

gridView.setOnItemClickListener(new GridView.OnItemClickListener(){
            @Override
            public void onItemClick(AdapterView parent, View view, int position, long id) {
                // chamar sua intent

            }

        });

Browser other questions tagged

You are not signed in. Login or sign up in order to post.