For an ICS based application, I created a ListFragment, which in turn uses the BaseAdapter implementation. I have included MultiChoiceModeListener () to display a contextual action bar. But the problem here is that whenever I check the CheckBox or press Label for a long time (both are in the view set in the BaseAdapter), the implementation of MultiChoiceModeListener is not called at all. Any help is much appreciated as I am completely stuck after many options!
public class ActivitiesFragment extends ListFragment {
public void onActivityCreated(Bundle savedInstanceState) {
Log.d(TAG, "Entering onActivityCreated()");
super.onActivityCreated(savedInstanceState);
this.setAdapter();
this.setHasOptionsMenu(true);
}
private void setAdapter() {
HashMap<String, String> activities = DBAdapter
.getInstance(this.context).getActivities();
setListAdapter(new ActivitiesList(Util.sortByComparator(activities)));
ListView listView = getListView();
listView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL);
listView.setMultiChoiceModeListener(new MultiSelectionListener());
}
private class ActivitiesList extends BaseAdapter {
@Override
public View getView(int position, View convertView, ViewGroup parent) {
ActivityView view = null;
String activityName = this.activityList.get(position);
String colour = this.activities.get(activityName);
if (convertView == null) {
view = new ActivityView(context, activityName, colour);
} else {
view = (ActivityView) convertView;
view.setActivityName(activityName);
}
return view;
}
}
private class MultiSelectionListener implements MultiChoiceModeListener {
}
}
source
share