Android 图像列表视图-将可绘制位置传递给下一个活动

Android 图像列表视图-将可绘制位置传递给下一个活动,android,image,listview,android-intent,drawable,Android,Image,Listview,Android Intent,Drawable,我有一个带有图像的ExpandableListView,当点击子对象时,它会在新活动中打开相同的图像 我无法获取drawable的位置,例如R.drawable.twitter,当我带着意图传递它时,所以如果你能解释我应该在这里插入什么myIntent.putExtraimage;我将非常感激 数组列表: 意向活动A: getIntent活动B: 试试这个 myIntent.putExtraimage,myList.getposition.getImage 然后在getIntentActivit

我有一个带有图像的ExpandableListView,当点击子对象时,它会在新活动中打开相同的图像

我无法获取drawable的位置,例如R.drawable.twitter,当我带着意图传递它时,所以如果你能解释我应该在这里插入什么myIntent.putExtraimage;我将非常感激

数组列表:

意向活动A:

getIntent活动B:

试试这个

myIntent.putExtraimage,myList.getposition.getImage

然后在getIntentActivity中使用它


希望对你有帮助

您只需要使用位置来抓取图像,只需在google中查找示例:我以前尝试过,我得到的方法getint对于ExpandableListView类型是未定义的,请在代码中使用arg3更改位置。我刚才没注意到谢谢你的提示!工作原理如下:myIntent.putExtraimage、Country listAdapter.getChildarg2、arg3.getImage;
  ArrayList<Country> countryList = new ArrayList<Country>();
  Country country = new Country("Where do I sign", R.drawable.twitter, "Tom Cruise", "TOP GUN");
  countryList.add(country);
  country = new Country("Count me in", R.drawable.facebook, "Jonah Hill", "21 JUMP STREET");
  countryList.add(country);
  country = new Country("Show me the money", R.drawable.facebook, "Tom  Cruise", "JERRY MAGUIRE");
  countryList.add(country);

  Continent continent = new Continent("Yes",countryList);
  continentList.add(continent);

  countryList = new ArrayList<Country>();
  country = new Country("I cant' do that", R.drawable.facebook, "Robert De Niro", "GOODFELLAS");
  countryList.add(country);
  country = new Country("Forget about it", R.drawable.facebook, "Johny Deep", "DONIE BRASCO");
  countryList.add(country);
  country = new Country("You have no power here", R.drawable.facebook, "Bernard Hill", "LORD OF THE RINGS");
  countryList.add(country);

  continent = new Continent("No",countryList);
  continentList.add(continent);
 public class Country {

 private String code = "";
 private int Image;
 private String actor = "";
 private String movie = "";

 public Country(String code, int Image, String actor, String movie) {
  super();
  this.code = code;
  this.Image = Image;
  this.actor = actor;
  this.movie = movie;
 }

 public String getCode() {
  return code;
 }
 public void setCode(String code) {
  this.code = code;
 }
 public int getImage() {
        return Image;
 }

 public void setImage(int Image) {
        this.Image = Image;
 }

 public String getActor() {
      return actor;
     }
 public void setActor(String actor) {
      this.actor = actor;
     }

 public String getMovie() {
      return movie;
         }
 public void setMovie(String movie) {
      this.movie = movie;
         }  
}
 myList.setOnChildClickListener(new OnChildClickListener() {

    @Override
    public boolean onChildClick(ExpandableListView arg0, View arg1, int arg2,
            int arg3, long arg4) {

        // TODO Auto-generated method stub
        Intent myIntent = new Intent(MainActivity.this, StartActivity.class);

        myIntent.putExtra("image", ------);

        MainActivity.this.startActivity(myIntent);

        return false;
    }
 });
 Intent myIntent = getIntent();

int image = myIntent.getIntExtra("image", 0);

ImageView imagefull = (ImageView)findViewById(R.id.imageView1);
imagefull.setImageResource(image);