1
나는 listview.any 도움에 관한 sdcard에서 모든 MP3 파일을 보여 주어야하는 응용 프로그램을 만들고 있습니다.Android : 목록보기에 mp3 파일보기
나는 listview.any 도움에 관한 sdcard에서 모든 MP3 파일을 보여 주어야하는 응용 프로그램을 만들고 있습니다.Android : 목록보기에 mp3 파일보기
여기는 Android 파일 탐색기를 기반으로 한 아주 좋은 예입니다. 그것은 당신의 sdcard에있는 모든 파일을 표시합니다.
확인이, http://android-er.blogspot.in/2010/01/implement-simple-file-explorer-in.html
지금 만 mp3 파일을 표시하려면, 당신은 단순히 파일 이름을 가진 상태 체크를해야한다.
는 getDir (문자열 dirPath)이 같은이 예제의 방법,private void getDir(String dirPath)
{
myPath.setText("Location: " + dirPath);
item = new ArrayList<String>();
path = new ArrayList<String>();
File f = new File(dirPath);
File[] files = f.listFiles();
if(!dirPath.equals(root))
{
item.add(root);
path.add(root);
item.add("../");
path.add(f.getParent());
}
for(int i=0; i < files.length; i++)
{
File file = files[i];
path.add(file.getPath());
if(file.isDirectory())
item.add(file.getName() + "/");
else
{
String filename=file.getName();
String ext = filename.substring(filename.lastIndexOf('.')+1, filename.length());
if(ext.equals("JPG")||ext.equals("jpg"))
{
item.add(file.getName());
}
}
}
ArrayAdapter<String> fileList =
new ArrayAdapter<String>(this, R.layout.row, item);
setListAdapter(fileList);
}
는 이제 탐색기하는 디스플레이에만 mp3 파일 준비를 교체합니다. 다음 코드는 오류주고
: 다른 \t { \t 문자열 EXT filename.substring = ('.'filename.lastIndexOf() + 1 filename.length()); \t if (ext.equals ("JPG") || ext.equals ("jpg")) \t { \t item.add (file.getName()); \t} \t} 여기서 mp3 형식이라고하는 파일명은 무엇입니까? –
대신 jpg를 mp3로 변경하십시오. 그리고 당신이 얻고있는 오류는 무엇입니까? –
파일 이름 –