80,472
社区成员




public void creatList(String[] data){
ArrayAdapter<String> adp=new ArrayAdapter<>(MainActivity.this,android.R.layout.simple_list_item_1,data);
View v=View.inflate(getApplicationContext(),R.layout.file_list,null);
ListView list=(ListView)v.findViewById(R.id.list_item);
list.setAdapter(adp);
}
dialog.setTitle("选择文件");
dialog.setCancelable(false);
dialog.setPositiveButton("确定", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
Toast.makeText(MainActivity.this,"你点击了确定",Toast.LENGTH_SHORT).show();
}
});
dialog.setNegativeButton("取消", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
Toast.makeText(MainActivity.this,"你点击了取消",Toast.LENGTH_SHORT).show();
}
});
dialog.setView(R.layout.file_list);
File files[]=getFileList(root);
String str[]=FileToString(files);
creatList(str);//传入列表的数据
dialog.show();