GridView on item click listener

13,206

does the gridView have a custom layout ?

if yes, go to the custom layout xml file and change these attributes

android:clickable="false"
android:focusable="false"
Share:
13,206
user2796963
Author by

user2796963

Updated on June 17, 2022

Comments

  • user2796963
    user2796963 almost 2 years
            gridView.setOnItemClickListener(new OnItemClickListener() {
            public void onItemClick(AdapterView<?> parent, View v,
                    int position, long id) {
                Toast.makeText(ScenesActivity.this, position + "#Selected",
                        Toast.LENGTH_SHORT).show();
    
                final Intent intent = new Intent(getApplicationContext(), ScenesDetailActivity.class);
                intent.putExtra(TestConstants.SELCTED_SCENE_KEY, position);
                startActivity(intent);
            }
    
        });
    

    TestConstants.java

    public interface TestConstants {
    
     String SELCTED_SCENE_KEY="SELCTED_SCENE"; }
    

    I want to get ScenesDetailActivity after click the slected scene key. It seems that the above code doesn't work as expected. Can someone help me to slove it? Thanks a lot! Simonides