Reputation: 484
I have an activity contains String
array, each String
is a drawable
image name, for example if I have an image called "abcd" then in the String
array the first value will be "abcd". I am trying to pass this String
array to another activity and then show there all the images.
First Activity:
Intent ip = new Intent(main3.this, main4.class);
ip.putExtra("p", usedcards1);
startActivity(ip);
Second Activity:
ImageView[] usedcardss;
RelativeLayout rel = (RelativeLayout) findViewById(R.id.main4con);
usedcardss = new ImageView[8];
RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
for (int i = 0; i < usedcardss.length; i++)
usedcardss[i] = new ImageView(this);
Intent pp = this.getIntent();
String[] cards = pp.getStringArrayExtra("p");
for (int i = 0; i < 8; i++) {
int icon = getResources().getIdentifier(cards[i], "drawable", getPackageName());
usedcardss[i].setImageResource(icon);
usedcardss[i].setLayoutParams(lp);
rel.addView(usedcardss[i]);
}
A new activity is created but it's simply blank. why?
Upvotes: 0
Views: 780
Reputation: 595
Maybe is not directly related to your issue but you are using a relative layout and im not seeing in your code where you are setting image layout parameters so that will cause imageViews to overlaps
Upvotes: 1