0

I would like to implements kind of onHover to my gridView. This is my current code:

    GridView gridView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        gridView = findViewById(R.id.emoji_grid);
        gridView.setAdapter(new ImageAdapter(this));
        gridView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View v,
                                    int position, long id) {
                Intent intent = new Intent(MainActivity.this, AfterChooseActivity.class);
                intent.putExtra("test", id);
                startActivityForResult(intent, 100);

            }
        });

That gave me the following view:

enter image description here

So I want that the background of each cell in the grid will be change when the mouse is on it. Is that possible?

Shahar
  • 33
  • 4

1 Answers1

0

GridView has no listener for hover events. I suggest you switch to using a RecyclerView and call setOnHoverListener on the view holders. The following links should help:

Nicolas
  • 6,611
  • 3
  • 29
  • 73