// Selected and deselect items and edit appropriate fragments public void onListItemClick(ListView l, View v, int position, long id) { super.onListItemClick(l, v, position, id); RadioButton routeSelected = (RadioButton) v.findViewById(R.id.radioButton1); ((MainActivity) getActivity()).routeElement = position; if (!routeSelected.isChecked()) { routeSelected.setChecked(true); adapter.setPositionSelected(((MainActivity) getActivity()).routeElement); ((MainActivity) getActivity()).setRoute(adapter.getRouteSelected()); ((MainActivity) getActivity()).selectedTrails = ((MainActivity) getActivity()).getAllRouteTrails(adapter.getRouteSelected()); } mSectionsPagerAdapter.notifyDataSetChanged(); }
public void onListItemClick(ListView l, View v, int position, long id) { super.onListItemClick(l, v, position, id); CheckBox trailCheck = (CheckBox) v.findViewById(R.id.checkBox1); ((MainActivity) getActivity()).routeElement = -1; if (!trailCheck.isChecked()) { trailCheck.setChecked(true); if (!((MainActivity) getActivity()) .selectedTrails.contains(adapter.getSelected(position))) { ((MainActivity) getActivity()).selectedTrails.add(adapter.getSelected(position)); } Log.v("check", Integer.toString(((MainActivity) getActivity()).selectedTrails.size())); } else { trailCheck.setChecked(false); remove(adapter.getSelected(position)); Log.v("uncheck", Integer.toString(((MainActivity) getActivity()).selectedTrails.size())); } ((MainActivity) getActivity()).update = true; mSectionsPagerAdapter.notifyDataSetChanged(); }