0
지정된 경로의 디렉토리에서 모든 이미지를로드하려고합니다. if 문을 사용하여 호출 된 경로를 확인하면 오류가 발생하지 않으며 결과도 표시되지 않습니다. 내가이 코드를 어디서 잘못 읽었는지 알 수는 없을 것이다.디렉토리에서 이미지 읽기
public class Edit extends Activity {
// File representing the folder that you select using a FileChooser
static final File dir = new File("/data/data/faceemoji.alexcz.yourfaceemoji/app_imageDir/");
// array of supported extensions (use a List if you prefer)
static final String[] EXTENSIONS = new String[]{
"png" // and other formats you need
};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_edit);
LinearLayout linearLayout = (LinearLayout)findViewById(R.id.linearlayout);
Log.d("loadfilepath", dir.getAbsolutePath());
if (dir.isDirectory()) { // make sure it's a directory
System.out.println("yes");
for (File f : dir.listFiles(IMAGE_FILTER)) {
Log.d("fak", "file found");
Bitmap myBitmap = BitmapFactory.decodeFile(f.getAbsolutePath());
ImageView myImage = new ImageView(this);
myImage.setImageBitmap(myBitmap);
linearLayout.addView(myImage);
}
}
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_edit, menu);
return true;
}
static final FilenameFilter IMAGE_FILTER = new FilenameFilter() {
@Override
public boolean accept(final File dir, final String name) {
for (String ext : EXTENSIONS) {
if (name.endsWith("." + ext)) {
return (true);
}
}
return (false);
}
};
}
확인이 [링크] (HTTP 있는지 확인하기 위해 로그인을했습니다. androhub.com/select-and-share-multiple-images/). –