So, I read this earlier question for ideas on how to allow me to click an item in a list to do one action or long press this item to switch to ActionMode, where I can select multiple items and use the ActionBar to do something with these elements. However, I am having problems with this answer . In particular, I implement this in a SherlockListFragment (using ActionBarSherlock). However, the moment I declare a new MultiChoiceModeListener, Eclipse throws a couple of compilation errors.
Description Resource Path Location Type Cannot override the final method from SherlockListFragment DateTimeListFragment.java /path/to/my/project line 127 Java Problem The method inflate(int, Menu) in the type MenuInflater is not applicable for the arguments (int, Menu) DateTimeListFragment.java /path/to/my/project line 125 Java Problem
This disappears when I remove the MultiChoiceModeListener. I have no idea what could be causing this, since there is nothing strange in what I know.
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { //super.onCreateOptionsMenu(menu, inflater); inflater.inflate(R.menu.alarmsmenu, menu); //line 125 } public boolean onOptionsItemSelected(MenuItem Item) //line 127 { switch(Item.getItemId()) { case R.id.addAlarm: addAlarm(); return true; case R.id.editAlarms: return true; default: return super.onOptionsItemSelected(Item); } }
I am very confused. Why does the implementation of MultiChoiceModeListener mean that I cannot override OnOptionsItemSelected?
EDIT: To clarify, here is my import.
import java.util.Calendar; import java.util.GregorianCalendar; import android.app.DatePickerDialog; import android.app.TimePickerDialog; import android.content.DialogInterface; import android.content.Intent; import android.database.Cursor; import android.os.Bundle; import android.support.v4.app.*; import android.support.v4.content.Loader; import android.view.View; import android.view.ViewGroup; import android.widget.AbsListView.MultiChoiceModeListener; import android.widget.AdapterView; import android.widget.AdapterView.OnItemLongClickListener; import android.widget.DatePicker; import android.widget.ListView; import android.widget.TimePicker; import com.actionbarsherlock.app.SherlockListFragment; import com.actionbarsherlock.app.ActionBar; //Yes, it unused... import com.actionbarsherlock.view.*; import com.commonsware.cwac.loaderex.acl.*;
Mowdownown
source share