Skip to content Skip to sidebar Skip to footer

Show Picture In Android App

I've written a quiz app with one question and three answers. The questions and answers are saved in a Frage object. For example: Frage f6 = new Frage(7, 'Welche Notrufnummer hat di

Solution 1:

You save your picture in your asset or drawable folder and show them via

Drawable:

ImageViewiv=newImageView(this); // (ImageView) findViewById(R.drawable.imageview);
iv.setImageResource( R.drawable.picture );

Assets:

try 
{
    // get input streamInputStreamims= getAssets().open("avatar.jpg");
    // load image as DrawableDrawabled= Drawable.createFromStream(ims, null);
    // set image to ImageView
    iv.setImageDrawable(d);
}
catch(IOException ex) 
{
    ex.printStackTrace();
}

In your case maybe save the resource id in your "Frage" object and give it your imageviee.

Fragef6=newFrage(7, "Welche Notrufnummer hat die Rettung in Österreich?", 
                     "166", "144", "110", "144", "bronze",R.drawable.austria_emergency_call);

besten Gruß

Post a Comment for "Show Picture In Android App"