ImageView가 포함 된 Android 앱을 쓰고 있습니다. 보기에 포함될 이미지는 에뮬레이터의 로컬 응용 프로그램 디렉토리에 있습니다. 이미지가 뷰에 표시되지 않습니다. 이미지를 표시하는 데 사용되는 relavent XML 및 메소드는 다음과 같습니다.Android : ImageView에 png 이미지를 표시 할 수 없습니다.
이미지 파일은 "png"형식의 파일이며 로컬 앱 디렉토리에서 열 수 있습니다. getFilesDir()에 의해 리턴 된 경로에는 "/data/data/net.vitalrecord.android/files"라는 전체 경로가 포함됩니다. 이 경로 지정은 개발 시스템에는 존재하지 않지만 DDMS 파일 탐색기가 사용될 때 존재합니다.
이 문제에 대한 도움을 주시면 대단히 감사하겠습니다.
감사합니다.
레이아웃 XML :
<AbsoluteLayout>
......
<ImageView
android:id="@+id/picture"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="100px"
android:layout_y="100px"/>
</AbsoluteLayout>
방법 : 공공 무효 checkFilesExists() {
.....
try {
Context context = getApplicationContext();
FILENAME = getString(R.string.MedicalImage);
fis = openFileInput(FILENAME);
int size = fis.available();
byte[] buffer = new byte[size];
fis.read(buffer);
fis.close();
setContentView(R.layout.medtogoimage);
ImageView iv = (ImageView)findViewById(R.id.picture);
String imagePath = context.getFilesDir() + "/" + FILENAME;
Drawable d = Drawable.createFromPath(imagePath);
iv.setImageDrawable(d);
medtogo.setbMedicalImageFileExists(true);
} catch (IOException e) {
medtogo.setbMedicalImageFileExists(false);
}
png 이미지가 다른 데이터 요소와 함께 원격 서버에서 스트림으로 검색되기 때문에 로컬 앱 디렉토리에 저장됩니다. 드로어 블 폴더는 읽기 전용 폴더입니다. 하지만 제안에 감사드립니다. – Roy