I tried to make general gridview and categorical gridview , from categorical gridview try to open clicked image in new activity .
THE PROBLEM IS WHEN click item in categorical gridview it doesn't open the new Activity
second gridview "categorical ":
holder.tv = (TextView) row.findViewById(R.id.textView1);
holder.img = (ImageView) row.findViewById(R.id.imageView1);
holder.tv.setText(Bresult[position]);
holder.img.setImageResource(BimageId[position]);
if (row == null) {
row = new ImageView(Bcontext);
}
row.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(Bcontext, BActivity.class).setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
if (position==0){
intent.putExtra("imageID", position);
Bcontext.startActivity(intent);
}
Toast.makeText(Bcontext, "You Clicked " + Bresult[position], Toast.LENGTH_LONG).show();
}
});
return row;
}
}
And this the New Activity should image appear there :
Intent intent = getIntent();
BCustomAdapter imageAdapter = new BirthCustomAdapter(this);
Bundle bdl = getIntent().getExtras();
int index = bdl.getInt("imageID");
ImageView image = (ImageView) findViewById(R.id.img_view);
image.setImageResource(index);
}
Aucun commentaire:
Enregistrer un commentaire