无法从 Android 中的资产文件夹成功加载图像

Can't successfully load image from Assets folder in Android

在我的代码中我没有错误,根本没有警告但是当我加载一个试图显示缩略图照片的布局时,位于资产文件夹中我看不到我的图像(“25.png”)显示在我的布局中。

我的 Java 文件是:

import android.app.Activity;
import android.os.Bundle;
import java.io.IOException;
import java.io.InputStream;
import android.graphics.drawable.Drawable;
import android.widget.ImageView;

public class Museum_Exhibit_Info extends Activity {

    ImageView mImage;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.exhibit_info);
        mImage = (ImageView)findViewById(R.id.mImage);
        loadDataFromAsset();

    }

        public void loadDataFromAsset() {

        // load image 
        try {
            // get input stream
            InputStream ims = getAssets().open("25.png");
            // load image as Drawable
            Drawable d = Drawable.createFromStream(ims, null);
            // set image to ImageView
            mImage.setImageDrawable(d);
        }
        catch(IOException ex) {
            return;
        }

    }

}

我的 xml 文件是:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
     >

    <ImageView
        android:id="@+id/mImage"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:contentDescription="@string/assets_image_number_25"
        />

</LinearLayout>

我真的不明白是什么问题。

我的 Logcat 是(从启动我的应用程序..在运行时):

    02-26 16:54:42.827: I/QCAR(2882): Configure Video Background : Video (640,480), Screen (1080,1920), mSize (1440,1920)
02-26 16:54:42.927: D/dalvikvm(2882): GC_EXPLICIT freed 536K, 17% free 22671K/27228K, paused 4ms+8ms, total 39ms
02-26 16:54:43.488: I/Choreographer(2882): Skipped 60 frames!  The application may be doing too much work on its main thread.
02-26 16:54:43.498: E/BufferQueue(2882): [unnamed-2882-1] dequeueBuffer: min undequeued buffer count (2) exceeded (dequeued=11 undequeudCount=0)
02-26 16:54:43.498: E/BufferQueue(2882): [unnamed-2882-1] dequeueBuffer: min undequeued buffer count (2) exceeded (dequeued=10 undequeudCount=1)
02-26 16:54:43.728: I/Adreno-EGL(2882): <qeglDrvAPI_eglInitialize:381>: EGL 1.4 QUALCOMM build:  (CL3869936)
02-26 16:54:43.728: I/Adreno-EGL(2882): OpenGL ES Shader Compiler Version: 17.01.11.SPL
02-26 16:54:43.728: I/Adreno-EGL(2882): Build Date: 01/17/14 Fri
02-26 16:54:43.728: I/Adreno-EGL(2882): Local Branch: 
02-26 16:54:43.728: I/Adreno-EGL(2882): Remote Branch: 
02-26 16:54:43.728: I/Adreno-EGL(2882): Local Patches: 
02-26 16:54:43.728: I/Adreno-EGL(2882): Reconstruct Branch: 
02-26 16:54:43.728: I/QCAR(2882): Creating OpenGL ES 2.0 context
02-26 16:54:43.838: D/QCAR(2882): GLRenderer::onSurfaceCreated
02-26 16:54:43.838: I/QCAR(2882): Java_com_qualcomm_QCARSamples_ImageTargets_ImageTargetsRenderer_initRendering
02-26 16:54:43.858: D/QCAR(2882): GLRenderer::onSurfaceChanged
02-26 16:54:43.858: I/QCAR(2882): Java_com_qualcomm_QCARSamples_ImageTargets_ImageTargetsRenderer_updateRendering
02-26 16:54:43.858: I/QCAR(2882): Configure Video Background : Video (640,480), Screen (1080,1920), mSize (1440,1920)
02-26 16:54:43.858: D/QCAR(2882): ImageTargets::updateRenderView
02-26 16:54:43.858: I/QCAR(2882): Java_com_qualcomm_QCARSamples_ImageTargets_ImageTargetsRenderer_updateRendering
02-26 16:54:43.858: I/QCAR(2882): Configure Video Background : Video (640,480), Screen (1080,1920), mSize (1440,1920)
02-26 16:54:43.858: I/QCAR(2882): Java_com_qualcomm_QCARSamples_ImageTargets_ImageTargets_setProjectionMatrix
02-26 16:54:46.541: I/System.out(2882): Cursor size 1

--->问题已解决<---

我的资产照片位于资产子文件夹中,因此我更改了代码

InputStream ims = getAssets().open("25.png");

String filename = "My assets subfolder name/"+ "25.png";
            InputStream ims = assetManager.open(filename);