Setting image based on user selection?
<p>I have an activity where the user can select their character. I have three image buttons on the screen and when the user clicks the character they want, I want the game to load another activity that will then just show an image of the character they selected in the previous screen. Basically this is just the forerunner for what I am going to do later. I found some examples on this website for how to accomplish this but I haven't quite gotten it all ironed out.</p>

<p>This is what I have in my character selection activity:</p>

<pre><code>Button archerButton = (Button) findViewById(R.id.Button_Archer);
archerButton.setOnClickListener(new View.OnClickListener() {
    public void onClick(View v) {
        Intent intent = new Intent(SelectCharacterActivity.this, LevelOneActivity.class);
        intent.putExtra("@drawable/archer", pathToImage);
        startActivity(intent);
        finish();
        }
    });
</code></pre>

<p>The pathToImage line is throwing an error. What exactly am I supposed to put here?</p>

<p>The LevelOne activity which is supposed to just display the image chosen has this:</p>

<pre><code>    public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
    setContentView(R.layout.level_one);



    String path = getIntent().getStringExtra("imagePath");
    Drawable image = Drawable.createFromPath(path);
    Character_Chosen.setImageDrawable(image);
    }
</code></pre>

<p>I'm a bit confused on this section as well. The Character_Chosen entry is the name of the imageview which should house the selected image.</p>

<p>I'm also confused on this line of code:</p>

<pre><code>String path = getIntent().getStringExtra("imagePath");
</code></pre>

<p>Does this mean I have to manually enter the image path every time? What if they choose a different image?</p>

<p>Does anyone have a link to an actual working example? Pseudo code doesn't really help me very much when I'm a novice and don't know what needs to stay and what needs to go.</p>
