我想将文件和文件夹列表添加到列表视图但无法这样做。我对android编程很陌生。请提供任何帮助
public void ftpPrintFilesList(String dir_path)
{
try {
FTPFile[] ftpFiles = mFTPClient.listFiles(dir_path);
int length = ftpFiles.length;
for (int i = 0; i < length; i++) {
String name = ftpFiles[i].getName();
boolean isFile = ftpFiles[i].isFile();
if (isFile) {
// Log.i(TAG, "File : " + name);
arrayList.add("File : " + name);
}
else {
Log.i(TAG, "Directory : " + name);
arrayList.add("Directory : " + name);
}
}
ListView lv;
lv = (ListView)findViewById(R.id.listView1);
lv.setAdapter(new ArrayAdapter<String>(MainActivity.this, android.R.layout.simple_list_item_1, arrayList));
} catch(Exception e) {
e.printStackTrace();
}
}