0

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?

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.