如何保存CHOICE MODE MULTIPLE

时间:2018-01-14 14:38:21

标签: android save multiple-choice

我想保存复选框。 如何保存CHOICE MODE MULTIPLE。

@Nullable     @覆盖     public View onCreateView(LayoutInflater inflater,@ Nullable ViewGroup container,Bundle savedInstanceState){         查看rootView = inflater.inflate(R.layout.fragment_check_tab1,container,false);

    mListView = (ListView) rootView.findViewById(R.id.check_ListView1);
    mListView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
    mListView.getCheckedItemPositions();

    ArrayAdapter adapter = new ArrayAdapter<String>(getContext(),android.R.layout.simple_list_item_multiple_choice, air_list);

    mListView.setItemChecked();
    mListView.setAdapter(adapter);

    return rootView;
}

class FM1Adapter extends BaseAdapter{

    @Override
    public int getCount() {
        return air_list.length;
    }

    @Override
    public Object getItem(int position) {
        return air_list[position];
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        TextView view = new TextView(getContext());
        view.setText(air_list[position]);
        view.setTextSize(30.f);
        view.setTextColor(Color.BLACK);
        view.setGravity(1);
        CheckBox box = new CheckBox(getContext());
        box.isChecked();
        return view;
    }

0 个答案:

没有答案