简体   繁体   English

如何在OnClickListener()LazyAdapter中调用新活动

[英]How to call a new activity in the OnClickListener () LazyAdapter

I want to call a new activity via click on the picture on the lazy adapter, but why in the following line appears Intent error "The constructor Intent(LazyAdapter, Class) is undefined" 我想通过单击惰性适配器上的图片来调用新活动,但是为什么在下一行中出现意图错误“构造函数Intent(LazyAdapter,Class)未定义”

// Click on Image
     gambar.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
            String strImageID = data.get(position).get("ImageID").toString();
            String strImageName = data.get(position).get("ImageName").toString();
            String strImagePathFull = data.get(position).get("ImagePathFull").toString();

            Intent newActivity = new Intent(LazyAdapter.this,VoteActivity.class); //Line error
            newActivity.putExtra("ImageID", strImageID);
            newActivity.putExtra("ImageName", strImageName);
            newActivity.putExtra("ImagePathFull", strImagePathFull);
            startActivity(newActivity); //line error
            }
        });

What steps am I doing wrong to call new activity in lazyadapter. 我在lazyadapter中调用新活动时做错了什么步骤。 I plan images on LazyList can be clicked, then appear a new activity with the bigger picture. 我计划在LazyList上的图像可以单击,然后以更大的图片显示一个新活动。 Please help, am I wrong to call a new activity. 请帮忙,我打错新活动了吗? What should I do so that the image can be clicked LazyList then performed with a full-size image and then do the voting. 我应该怎么做才能使该图像可以单击LazyList,然后对全尺寸图像执行,然后进行投票。

It should be context of your Activity not the Adapter class, 它应该是您Activity的上下文,而不是Adapter类,

Intent newActivity = new Intent(YourActivity.this,VoteActivity.class);

instead of 代替

Intent newActivity = new Intent(LazyAdapter.this,VoteActivity.class);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM