代码如下,想要实现点击一个checkBox之后,弹出一个dialog,其中用listview来显示带有图标和应用信息的列表,但是运行之后会闪退,提示
listview.setAdapter(browseAppAdapter);
这行代码空指针错误,求解
checkBox.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
if (checkBox.isChecked()) {
final Dialog dialog = new Dialog(getActivity());
dialog.setContentView(R.layout.browse_app_list);
dialog.setTitle("应用列表");
mlistAppInfo = new ArrayList<AppInfo>();
queryAppInfo(); // 查询所有应用程序信息
BrowseApplicationInfoAdapter browseAppAdapter = new BrowseApplicationInfoAdapter(
getActivity(), mlistAppInfo);
listview.setAdapter(browseAppAdapter);
listview.setOnItemClickListener(new OnItemClickListener(){
@Override
public void onItemClick(AdapterView<?> arg0, View arg1,
int position, long arg3) {
// TODO Auto-generated method stub
intent = mlistAppInfo.get(position).getIntent();
}
});
dialog.show();
}
}
});