我正在尝试创建一个 DialogFragment,它显示一个内部带有自定义 ListView 的对话框。
public class MultiSelectDialogCustom extends DialogFragment {
ListView mLocationList;
private ArrayList<String> mOfficeListItems = new ArrayList<String>();
public static MultiSelectDialogCustom newInstance(int title) {
MultiSelectDialogCustom dialog = new MultiSelectDialogCustom();
Bundle args = new Bundle();
args.putInt("title", title);
dialog.setArguments(args);
return dialog;
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
Collections.addAll(mOfficeListItems, getResources().getStringArray(R.array.offices));
View v = inflater.inflate(R.layout.fragment_choice_list, container,
true);
mLocationList = (ListView)v.findViewById(R.id.location_criteria_list);
final FunctionListArrayAdapter adapter = new FunctionListArrayAdapter(
this, android.R.layout.simple_list_item_1, mOfficeListItems);
mLocationList.setAdapter(adapter);
getDialog().setTitle(getArguments().getInt("title"));
return v;
}
}
从片段调用它时:
MultiSelectDialogCustom dialogFrag = MultiSelectDialogCustom_.newInstance(R.string.dialog_title);
dialogFrag.show(getActivity().getSupportFragmentManager(), null);
它只显示一个带有标题的空白对话框......为什么我的列表没有显示?