【发布时间】:2015-05-08 18:59:17
【问题描述】:
我正在 android 中制作文件资源管理器。因此,我希望在单击目录以外的任何文件时,我想获得可以打开它的应用程序的建议,如果没有应用程序,则显示一个dailog。我尝试了一些解决方案,但没有任何效果,所以,现在,我只是显示文件不是 toast 中的目录
这里是部分代码:
protected void onListItemClick(ListView l, View v, int position, long id) {
String filename = (String) getListAdapter().getItem(position);
if (path.endsWith(File.separator)) {
filename = path + filename;
} else {
filename = path + File.separator + filename;
}
if (new File(filename).isDirectory()) {
Intent intent = new Intent(this, ListFileActivity.class);
intent.putExtra("path", filename);
startActivity(intent);
} else {
Toast.makeText(this, filename + " is not a directory", Toast.LENGTH_LONG).show();
}
}
【问题讨论】:
-
“我尝试了一些解决方案,但没有任何效果”——我们应该如何帮助您处理您没有向我们展示的代码?
标签: java android android-intent