コード例 #1
0
  public void addSelectedToDatabase(Context context) {
    List<Computation> selected = SetupCompsFragment.getSelectedComps();

    TworkDBHelper db = TworkDBHelper.getHelper(context);

    for (Computation comp : selected) {
      db.addComputation(
          comp.getId(),
          comp.getName(),
          comp.getDescription(),
          comp.getTopics(),
          TworkDBHelper.COMP_STATUS_ACTIVE);
      Log.i("SQLite", "added" + comp.getName());
    }
  }
コード例 #2
0
  public void populateList(final Context context, View view) {
    allComps = CompService.getComputations(TworkDBHelper.getHelper(getContext()));
    CompsArrayAdapter adapter = new CompsArrayAdapter(context, allComps);

    listView = (ListView) view.findViewById(R.id.comps_list_view);
    listView.setAdapter(adapter);
    listView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);

    listView.setOnItemClickListener(
        new AdapterView.OnItemClickListener() {
          @Override
          public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            Intent intent = new Intent(context, CompDetailActivity.class);
            intent.putExtra(CompDetailFragment.ARG_ITEM_ID, position);
            intent.putExtra(CompDetailFragment.ARG_COMPS_LIST, CompDetailFragment.LIST_ALL_COMPS);

            context.startActivity(intent);
          }
        });
  }