弹窗中加入的列表数据怎么不显示出来?

coclyun coclyun 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
这个是代码
我用了另一个布局文件file_list,这个布局文件作为弹窗的自定义布局,里面只有一个ListView
但是我向列表加入数据后没有显示出来?这是为什么,传入的data数组没问题

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();

...全文
评论 4
收藏 已收藏
分享
返回顶部
coclyun
Android 80,489 成员 91,375 内容