【发布时间】:2016-05-04 11:03:04
【问题描述】:
我创建了 2 个微调器,我需要让用户能够从每个微调器中选择多个东西。我设法通过 android.R.layout.simple_list_item_multiple_choice 添加复选框。现在我设法得到了我想要的一切,但问题是如何让用户选择多个已经有复选框的东西,但是当用户点击某个项目时,它会立即关闭微调器并在该项目上保持选中状态。
这是我得到并且想要的设计,但问题在于选择。
http://pokit.org/get/?1c872c5becdeb79b792617fc870f1da4.jpg 这是选择: http://pokit.org/get/?e892ee2f941ab3f98b8ee51e6f9e8fc6.jpg
这是该微调器的当前代码:
public void onViewCreated(View view, Bundle savedInstanceState) {
Spinner placesspinner=(Spinner)getActivity().findViewById(R.id.spinner_locations);
Spinner catspinner=(Spinner)getActivity().findViewById(R.id.spinner_category);
ArrayAdapter<String> adp1=new ArrayAdapter<String>(getContext(),android.R.layout.simple_list_item_multiple_choice,places);
placesspinner.setAdapter(adp1);
catspinner.setAdapter(adp1);
// Setup any handles to view objects here
// EditText etFoo = (EditText) view.findViewById(R.id.etFoo);
}
【问题讨论】:
标签: java android android-layout android-studio android-spinner