1

我尝试通过单击完整图像来完成此活动。然后它应该从它被选择的地方返回到 gridview 活动。但我只是无法将其编写代码,eclipse 一直告诉我 [ The method setOnItemClickListener(new AdapterView.OnItemClickListener(){}) is undefined for type ImageView ] on the setOnItemClickListener。

这里是全屏图像的活动:

package com.sjapp.picsnd4;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.widget.AdapterView;
import android.widget.ImageView;
import android.widget.AdapterView.OnItemClickListener;
import android.view.View;
public class FullImageActivity extends Activity {

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.full_image);

    // get intent data
    Intent i = getIntent();

    // Selected image id
    int position = i.getExtras().getInt("id");
    ImageAdapter imageAdapter = new ImageAdapter(this);

    ImageView imageView = (ImageView) findViewById(R.id.full_image_view);
    imageView.setImageResource(imageAdapter.mThumbIds[position]);

    ImageView fsImage = (ImageView) findViewById(R.id.fullimage_id);

    fsImage.setOnItemClickListener(new OnItemClickListener() {

    @Override
    public void onItemClick(AdapterView parent, View v,
    int position, long id) {

    finish();
    }
    }); 

}

}

有任何想法吗?

4

2 回答 2

1

用于onClickListener()imageView,onItemClickListener用于 ListView、gridView 等视图。

于 2012-02-19T12:08:42.400 回答
1

ImageView 不是 AdapterView。只需使用 View.onClickListener。它会起作用的。

于 2012-02-19T12:14:35.507 回答