How to add gridview setOnItemClickListener

后端 未结 6 1330
难免孤独
难免孤独 2020-12-16 14:42

I have a GridView with 81 buttons on it. I want to add clicklistener to this gridview but it is not available. I have added the OnItemClickListener but it is not working and

6条回答
  •  被撕碎了的回忆
    2020-12-16 15:17

    If you want to get text that clicked item you can use this

    gridView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
                @Override
                public void onItemClick(AdapterView adapterView, View view, int i, long l) {
                    String item = ((TextView)view.findViewById(R.id.ID_OF_TEXTVIEW)).getText().toString();
                    Toast.makeText(showMissions.this, "" + item, Toast.LENGTH_SHORT).show();
    
                }
            });
    

提交回复
热议问题