GridView中关于项目点击监听器监听器、项目、GridView

2023-09-06 23:04:41 作者:旧人不覆.

        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

TestConstants.java

public interface TestConstants {

 String SELCTED_SCENE_KEY="SELCTED_SCENE"; }

我想以后得到ScenesDetailActivity点击slected场景关键。如此看来,预期上述code不起作用。谁能帮我解决售后服务呢?多谢!西蒙尼特斯

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

推荐答案

确实在GridView有一个自定义布局?

does the gridView have a custom layout ?

如果是,进入自定义布局的XML文件,并修改这些属性。

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

android:clickable="false"
android:focusable="false"