2015-11-13 68 views

回答

0

首先,你需要創建一個ImageView然後通過代碼設置的圖像資源,即可ImageView低於

yourImageview.setImageResource(id); // id is your Integer resource 

希望這有助於

-1

只需將資源ID設置爲您的ImageView參照物像

ImageView imageView = (ImageView) findViewById(R.id.yourImageView); 
// and then set the resource id to your imageView 
imageView.setImageResource(resourceID); 
0

是的。我之前嘗試過,但爲了在這種情況下完成工作,我們還需要一件事。圖像是不同包裝的資源。這裏

解決辦法是:

Resources resources; 
    Bitmap bitmap = null; 
    try { 
     PackageManager manager = getPackageManager(); 
     resources = manager.getResourcesForApplication(packageName); 

     Drawable image = resources.getDrawable(some_resource_int_id, null); 
     bitmap = ((BitmapDrawable)image).getBitmap(); 
    } 
    catch (PackageManager.NameNotFoundException e) { 
    } 
相關問題