I have a listview with a custon adapter. I have to put a context menu for it, but it's not working. And I put the onItemLongClick to the list and it's not working too. I don't know how to trigger the contextmenu. If I have to click on an item or long click on it. I do register a long click to get the id from the item.
EDIT I think i figure out whats the problem. I have a button on my item listview. I remove this button from the layout and the context menu worked fine. But I need this button. Why the button was causing problem in the context menu?
This is the class:
public class HistoricoDespesasActivity extends Activity {
Helper h;
AlphaAnimation buttonClick;
DespesasDAO dDAO;
ListView lv;
DespesaHistoricoAdapter adapter;
int idDespesasSelecionada;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_historico_despesas);
lv = (ListView)findViewById(R.id.lvHistoricoDespesas);
TextView tvMarcaModelo = (TextView)findViewById(R.id.tvMarcaModeloCabecalho);
TextView tvApelido = (TextView)findViewById(R.id.tvApelidoCabecalho);
tvApelido.setVisibility(View.INVISIBLE);
tvMarcaModelo.setVisibility(View.INVISIBLE);
buttonClick = new AlphaAnimation(1, 0.5f);
h = new Helper(this);
h.mostraVeiculoAtivo();
adapter = new DespesaHistoricoAdapter(this);
dDAO = new DespesasDAO(this);
dDAO.open();
Cursor cursor = dDAO.consultarTodasDespesasByIdVeiculo(h.getId());
int id;
String data;
String tipoDespesa = null;
double valor;
int tipo = 0;
if(cursor != null && cursor.moveToFirst()){
do {
id = cursor.getInt(cursor.getColumnIndex(DespesasDAO.COLUNA_ID));
data = cursor.getString(cursor.getColumnIndex(DespesasDAO.COLUNA_DESPESA_DATA));
tipo = cursor.getInt(cursor.getColumnIndex(DespesasDAO.COLUNA_ITEM_ID));
valor = cursor.getDouble(cursor.getColumnIndex(DespesasDAO.COLUNA_DESPESA_VALOR));
if(tipo == 1){
tipoDespesa = "Pedágio";
} else if(tipo == 2){
tipoDespesa = "Estacionamento";
} else if(tipo == 3){
tipoDespesa = "Lavagem";
} else if(tipo == 4){
tipoDespesa = "Diversos";
}
adapter.addDespesa(id, tipoDespesa, data, valor);
} while (cursor.moveToNext());
cursor.close();
dDAO.close();
lv.setAdapter(adapter);
}
lv.setLongClickable(true);
lv.setOnItemLongClickListener(new OnItemLongClickListener() {
#Override
public boolean onItemLongClick(AdapterView<?> parent, View view,
int position, long id) {
idDespesasSelecionada = (Integer) parent.getItemAtPosition(position);
return true;
}
});
registerForContextMenu(lv);
}
#Override
public void onCreateContextMenu(ContextMenu menu, View v,
ContextMenuInfo menuInfo) {
super.onCreateContextMenu(menu, v, menuInfo);
menu.setHeaderTitle("Despesas");
menu.add(0, v.getId(), 0, "Deletar");
}
#Override
public boolean onContextItemSelected(MenuItem item) {
if(item.getTitle().equals("Deletar")){
dDAO.open();
dDAO.removerDespesasById(idDespesasSelecionada);
dDAO.close();
}
onCreate(new Bundle());
return super.onContextItemSelected(item);
}
#Override
protected void onResume() {
onCreate(new Bundle());
super.onResume();
}
}
Remove your setOnItemLongClickListener of listView and replace onContextItemSelected with this
#Override
public boolean onContextItemSelected(MenuItem item)
{
AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();
if(item.getTitle().equals("Deletar"))
{
dDAO.open();
dDAO.removerDespesasById(info.position);
dDAO.close();
}
return true;
}
change onCreateContextMenu like this :
#Override
public void onCreateContextMenu(ContextMenu menu, View v,ContextMenuInfo menuInfo) {
super.onCreateContextMenu(menu, v, menuInfo);
MenuInflater inflater =getMenuInflater();
inflater.inflate(R.menu.more_tab_menu, menu);
}
see this topic :
Android, How to create Context Menu...
EDIT :
use button. image Button and list view is clickable. if you use Button and set android:focusable="false" android:focusableInTouchMode="false" work fine.
Related
I need to get for example the second patient in the list, it is always the first position and my int is always 0, there's no way to get the real position when I click any position, here is my code:
public void setupGUI() {
listView = findViewById(R.id.listView);
if (getIntent().getParcelableExtra(Constants.PARCELABLE_TAG) != null) {
user = getIntent().getParcelableExtra(Constants.PARCELABLE_TAG);
GetDoctor gd = new GetDoctor(DoctorMenu.this, user.getId(), user.getToken());
gd.execute();
if (user != null) {
userToken = user.getToken();
FillPatientsTask fpt = new FillPatientsTask(DoctorMenu.this, this, userToken, null);
fpt.execute();
} else {
userToken = "";
Toast.makeText(this, "User was null", Toast.LENGTH_SHORT).show();
}
}
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
#Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
numberPatient = position;
}
});
registerForContextMenu(listView);
}
#Override
public void onCreateContextMenu(ContextMenu menu, View v,
ContextMenu.ContextMenuInfo menuInfo) {
super.onCreateContextMenu(menu, v, menuInfo);
AdapterView.AdapterContextMenuInfo info =
(AdapterView.AdapterContextMenuInfo) menuInfo;
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.options_patient_menu, menu);
patient = items.get(numberPatient);
}
It will be ever zero why collections begin with first position as 0 position. For your case, try as follow:
numberPatient = position + 1;
I have a dialog that shows a list of items, I need to be able to edit/delete items in this list so I put a context menu in so when the user long presses on an item it they can choose what they want to do (edit or delete the item).
The problem is that onContextItemSelected never gets called when an item in the context menu is selected.
I checked to see if maybe the activity that created the dialog fragment is getting the callback but that is not either so why is there it not getting called? Can you not do a context menu in a dialog?
public class TypesDialogList extends DialogFragment implements LoaderManager.LoaderCallbacks<Cursor>,OnItemClickListener,OnCreateContextMenuListener{
ListView lv;
SimpleCursorAdapter mAdapter;
private int EDIT_TYPE = 1;
private int DELETE_TYPE = 2;
OnEditType mType;
public Dialog onCreateDialog(Bundle state){
final View v = getActivity().getLayoutInflater().inflate(R.layout.layer_dialog_layout, null, false);
lv = (ListView)v.findViewById(R.id.listView1);
lv.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
lv.setOnItemClickListener(this);
lv.setOnCreateContextMenuListener(this);
return new AlertDialog.Builder(getActivity()).setView(v).setPositiveButton("Add Type", new OnClickListener(){
public void onClick(DialogInterface dialog, int which) {
}
}).setTitle("Type's").create();
}
#Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo){
super.onCreateContextMenu(menu, v, menuInfo);
AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuInfo;
long id = info.id;
if(id > 3){
menu.setHeaderTitle("Type Menu");
menu.add(Menu.NONE, EDIT_TYPE, 1, "Edit");
menu.add(Menu.NONE, DELETE_TYPE, 2, "Delete");
}else{
Toast.makeText(getActivity(),"Cannot edit type",Toast.LENGTH_SHORT).show();
}
}
#Override
public boolean onContextItemSelected(MenuItem item) {
super.onContextItemSelected(item);
AdapterView.AdapterContextMenuInfo oMenuInfo = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo();
long id = oMenuInfo.id;
if(item.getItemId() == EDIT_TYPE){
}else if(item.getItemId() == DELETE_TYPE){
}
return true;
}
}
For anybody still looking for a workaround, I just solved this problem by creating an anonymous OnMenuItemClickListener that delegates back to onContextItemSelected(MenuItem item) and setting it on all the items in my menu.
#Override
public void onCreateContextMenu(ContextMenu menu, View view, ContextMenuInfo menuInfo) {
// Creation/inflate menu here
OnMenuItemClickListener listener = new OnMenuItemClickListener() {
#Override
public boolean onMenuItemClick(MenuItem item) {
onContextItemSelected(item);
return true;
}
};
for (int i = 0, n = menu.size(); i < n; i++)
menu.getItem(i).setOnMenuItemClickListener(listener);
}
I have created a context menu. The context menu appears, when I do a longclick on the listitems. So far so good...
But when i click on a contextitem, nothing happens. Does anyone know this issue?
What's the problem here?
Button for opening the dialog with listview:
Button cmd_fav = (Button) findViewById(R.id.cmd_main_fav);
cmd_fav.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
List<String> valueList = new ArrayList<String>();
db = SQLiteDatabase.openDatabase("/data/data/spicysoftware.abugrundwissen/databases/questions", null,
SQLiteDatabase.OPEN_READWRITE);
Cursor c_ = db.rawQuery("SELECT question, _id, answer FROM tbl_questions"+
" where favourite = 1", null);
if (c_ != null ) {
if (c_.moveToFirst()) {
do {
String str_question = c_.getString(c_.getColumnIndex("question"));
valueList.add(str_question);
} while (c_.moveToNext());
}
// custom dialog
dialog = new Dialog(MainSite.this);
dialog.setContentView(R.layout.dialog_list);
dialog.setTitle("Favoriten:");
adapter = new ArrayAdapter<String>(MainSite.this, android.R.layout.simple_list_item_1, valueList);
final ListView lv = (ListView)dialog.findViewById(R.id.list_search);
lv.setAdapter(adapter);
registerForContextMenu(lv);
lv.setOnCreateContextMenuListener(new OnCreateContextMenuListener() {
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
menu.add(Menu.NONE, CONTEXT_MENU_DELETE_ITEM, Menu.NONE, "Favorit entfernen");
menu.add(Menu.NONE, CONTEXT_MENU_FINISH_ITEM, Menu.NONE, "Frage abschliessen!");
}
});
lv.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
lv.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View view, final int position, long id) {
String item = (String) lv.getItemAtPosition(position).toString();
Cursor c_2 = db.rawQuery("SELECT answer FROM tbl_questions"+
" where question = '"+item+"'", null);
if (c_2 != null ) {
if (c_2.moveToFirst()) {
answer = c_2.getString(c_2.getColumnIndex("answer"));
}
}
// custom dialog
final Dialog dialog = new Dialog(MainSite.this);
dialog.setContentView(R.layout.dialog_answer);
dialog.setTitle("Antwort:");
// set the custom dialog components - text, image and button
TextView text = (TextView) dialog.findViewById(R.id.txt_answer);
//text.setText(answer);
text.setText(Html.fromHtml(answer), TextView.BufferType.SPANNABLE);
Button dialogButton = (Button) dialog.findViewById(R.id.cmd_close_dialog);
// if button is clicked, close the custom dialog
dialogButton.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
dialog.dismiss();
}
});
dialog.show();
}
});
Button dialogButton = (Button) dialog.findViewById(R.id.cmd_close_dialog2);
// if button is clicked, close the custom dialog
dialogButton.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
dialog.dismiss();
}
});
dialog.show();
}
}
});
OnContextItemSelected:
#Override
public boolean onContextItemSelected(MenuItem item) {
Log.v("tst", "lol");
switch (item.getItemId()) {
case CONTEXT_MENU_DELETE_ITEM:
Log.v("DELETED", "TRUE");
return true;
case CONTEXT_MENU_FINISH_ITEM:
Log.v("FINISHED", "TRUE");
return true;
}
Log.v("FINISHED", "LOL");
return false;
}
Best Regards
MSeiz5
I found a solution here Android: ContextMenu and ItemSelected in Context Menu
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
super.onCreateContextMenu(menu, v, menuInfo);
//MenuInflater inflater = getMenuInflater();
//inflater.inflate(R.menu.context_menu, menu);
MenuItem delete = menu.add("delete");
MenuItem add = menu.add("add");
add.setIcon(android.R.drawable.ic_menu_upload); //adding icons
delete.setOnMenuItemClickListener(new OnMenuItemClickListener() {
public boolean onMenuItemClick(MenuItem item) {
Log.d("ContextCheck","EDIT!");
Toast.makeText(Pr.this, "Edit!", Toast.LENGTH_SHORT).show();
return true;
}
});
add.setOnMenuItemClickListener(new OnMenuItemClickListener() {
public boolean onMenuItemClick(MenuItem item) {
Log.d("ContextCheck","EDIT!");
Toast.makeText(Pr.this, "Edit!", Toast.LENGTH_SHORT).show();
return true;
}
});
}
Is Working!
If MenuInflater used, more generic code:
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.ruleitem_menu, menu);
if (menuInfo instanceof AdapterView.AdapterContextMenuInfo){
AdapterView.AdapterContextMenuInfo adptrCmi = (AdapterContextMenuInfo) menuInfo;
String lsItem = currentRuleListView.getItemAtPosition(adptrCmi.position).toString();
menu.setHeaderTitle( lsItem);
}
//if Activity.onContextItemSelected not triggered, try the following lines
for (int i=0; i< menu.size();i++){
menu.getItem(i).setOnMenuItemClickListener(new OnMenuItemClickListener(){
#Override
public boolean onMenuItemClick(MenuItem item) {
return onContextItemSelected(item);
}
});
}
I have a ListFragment where I would like to add a normal click listener and a long one.
I override the onListItemClick() method on the ListFragment. Here, there is no problem it works.
Then I created an Adapter where I added an OnLongClickListener through setOnLongClickListener() in the getView() method:
public class QuestionsAdapter extends BaseAdapter {
private QuestionsBean questions = null;
private LayoutInflater inflater = null;
public QuestionsAdapter(LayoutInflater inflater) {
this.inflater = inflater;
}
#Override
public int getCount() {
return (questions != null && questions.getQuestionList() != null) ? questions.getQuestionList().size() : 0;
}
#Override
public Object getItem(int position) {
return (questions != null && questions.getQuestionList() != null) ? questions.getQuestionList().get(position) : null;
}
#Override
public long getItemId(int position) {
return position;
}
#Override
public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder holder;
QuestionBean question = ((QuestionsBean) questions).getQuestionList().get(position);
if (convertView == null) {
holder = new ViewHolder();
convertView = inflater.inflate(R.layout.item_fragment_question, null);
holder.questionItem = (TextView) convertView.findViewById(R.id.itemFragmentQuestions);
holder.questionItem.setOnLongClickListener(new View.OnLongClickListener() {
#Override
public boolean onLongClick(View v) {
System.out.println("test => it works");
;
return false;
}
});
convertView.setTag(holder);
} else {
holder = (ViewHolder) convertView.getTag();
}
holder.questionItem.setText(question.getQuestion());
return convertView;
}
private class ViewHolder {
TextView questionItem;
}
public void setQuestions(QuestionsBean questions) {
List<QuestionBean> temp = new ArrayList<QuestionBean>();
if (questions != null && questions.getQuestionList() != null) {
for (QuestionBean question : questions.getQuestionList()) {
if (question.isActivated()) {
temp.add(question);
}
}
questions.setQuestionList(temp);
}
this.questions = questions;
notifyDataSetChanged();
}
}
Now, the longClickListener works but not the normal click anymore (actually it works like one time out of 10, or 15 or 20 (it depends...).
I have no idea why when I set both listener, the onListItemClick() doesn't work.
Any idea ?
Thanks for you help.
EDIT: My row xml
<TextView
android:id="#+id/itemFragmentQuestions"
style="#style/ItemFragmentQuestion"
android:layout_marginBottom="#dimen/itemFragmentQuestionsMarging"
android:background="#drawable/background_validated" >
</TextView>
</LinearLayout>
EDIT:
My ListFragment class:
public class QuestionsFragment extends ListFragment {
public static final int VALIDATED = 1;
public static final int IN_PROGRESS = 1;
public static final int NON_OBSERVED = 1;
private QuestionsAdapter adapter;
private QuestionsBean questions;
public QuestionsFragment() {
}
public QuestionsFragment(QuestionsBean questions) {
this.questions = questions;
}
public int getShownIndex() {
return getArguments() != null ? getArguments().getInt("index", 0) : 0;
}
#Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
this.adapter = new QuestionsAdapter(inflater);
registerForContextMenu(getListView());
View questionsView = (LinearLayout) inflater.inflate(R.layout.fragment_questions, null);
setListAdapter(adapter);
return questionsView;
}
#Override
public void onListItemClick(ListView l, View v, int position, long id) {
super.onListItemClick(l, v, position, id);
if (l == this.getListView()) {
QuestionBean question = (QuestionBean) l.getItemAtPosition(position);
TextView textView = (TextView) v.findViewById(R.id.itemFragmentQuestions);
switch (question.getValue()) {
case QuestionBean.OK:
question.setValue(QuestionBean.NOK);
textView.setBackgroundResource(R.drawable.background_in_progress);
break;
case QuestionBean.NOK:
question.setValue(QuestionBean.NA);
textView.setBackgroundResource(R.drawable.background_non_observed);
break;
case QuestionBean.NA:
question.setValue(QuestionBean.OK);
textView.setBackgroundResource(R.drawable.background_validated);
break;
}
}
}
#Override
public void onResume() {
super.onResume();
refresh(this.questions);
}
public void refresh(QuestionsBean questions) {
this.questions = questions;
adapter.setQuestions(questions);
}
#Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
super.onCreateContextMenu(menu, v, menuInfo);
menu.setHeaderTitle("Menu Title");
menu.add(0, v.getId(), 0, "Option 1");
menu.add(0, v.getId(), 0, "Option 2");
}
#Override
public boolean onContextItemSelected(MenuItem item) {
AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();
if (item.getTitle() == "Option 1") {
// Option 1 code here
} else if (item.getTitle() == "Option 2") {
// Option 2 code here
}
return super.onContextItemSelected(item);
}
}
#Barak As you can see, I set the Adapter in onCreateView() and when I put registerForContextMenu(getListView()) right after, I get an error. It seems that getListView() isn't set yet.
Why not use a context menu for the long click rather than muck about in the adapter?
registerForContextMenu(getListView());
and then:
#Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
super.onCreateContextMenu(menu, v, menuInfo);
menu.setHeaderTitle("Menu Title");
menu.add(0, v.getId(), 0, "Option 1");
menu.add(0, v.getId(), 0, "Option 2");
}
#Override
public boolean onContextItemSelected(MenuItem item) {
AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();
if (item.getTitle().equals("Option 1")) {
// Option 1 code here
} else if (item.getTitle().equals("Option 2")) {
// Option 2 code here
}
return super.onContextItemSelected(item);
}
I think you should use listView.setOnItemLongClickListener(...); instead of listView.setOnLongClickListener(...);.
Sorry for tearing up healing wounds :-)
I have a list activity, and I chose to manually add the first item which is "add new item...".
I have registered the context menu for the whole listview, using registerForContextMenu(getListView()); straight into the onCreate.
When the context menu is build, the system calls onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo). The View v is the listView, and I cannot find a way to know which item in the listview is being long-pressed.
I could create a xml layout, with a layout for the "add new item..." and add a listview after, which would be populated by the activity, and that would react to the context menu, but I'm sure there is a way to solve this problem without any xml layout.
I have tried to register each view inside my listview using registerForContextMenu, which works, however the listview doesn't respond to touch anymore.
Here is my activity code listing:
public class AMain extends ListActivity {
private List<String> pregList;
private List<Long> pregIds;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
pregList = new ArrayList<String>();
pregIds = new ArrayList<Long>();
registerForContextMenu(getListView());
}
#Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
super.onCreateContextMenu(menu, v, menuInfo);
// TODO: hide the menu for the 1st item!!
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.context_menu, menu);
}
#Override
public boolean onContextItemSelected(MenuItem item) {
AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();
Logger.d("id = "+info.id);
switch (item.getItemId()) {
case R.id.menu_show:
showPregnancy((int) info.id);
return true;
case R.id.menu_edit:
editPregnancy((int) info.id);
return true;
case R.id.menu_delete:
//TODO: do the deletion
return true;
default:
return super.onContextItemSelected(item);
}
}
protected void onStart() {
super.onStart();
clearPregList();
loadPregList();
getListView().setAdapter(new PregnancyListAdapter(this));
}
void clearPregList() {
pregList.clear();
pregIds.clear();
}
void loadPregList() {
PregnanciesDbAdapter db = new PregnanciesDbAdapter(this);
db.open();
Cursor c = db.getPregnancies();
if (c != null) {
do {
pregList.add(c.getString(c.getColumnIndex(PregnanciesDbAdapter.KEY_PREG_NOM)));
pregIds.add(c.getLong(c.getColumnIndex(PregnanciesDbAdapter.KEY_PREG_ROWID)));
} while (c.moveToNext());
c.close();
}
db.close();
}
private class PregnancyListAdapter extends BaseAdapter {
private Context context;
public PregnancyListAdapter(Context ctx) {
context = ctx;
}
#Override
public int getCount() {
return pregList.size()+1;
}
#Override
public Object getItem(int position) {
if (position == 0) { // add button
return getString(R.string.addPreg);
} else {
return pregList.get(position-1);
}
}
#Override
public long getItemId(int position) {
if (position == 0) {
return -1;
}
return pregIds.get(position-1);
}
#Override
public View getView(int position, View convertView, ViewGroup parent) {
LinearLayout itemLayout;
itemLayout= (LinearLayout) LayoutInflater.from(context).inflate(R.layout.homelist_item_pregnancy, parent, false);
ImageView logo = (ImageView) itemLayout.findViewById(R.id.logo);
TextView pregName = (TextView) itemLayout.findViewById(R.id.pregName);
if (position == 0) {
itemLayout.setFocusable(false);
itemLayout.setFocusableInTouchMode(false);
pregName.setText(getString(R.string.addPreg));
} else {
logo.setVisibility(View.INVISIBLE);
pregName.setText(pregList.get(position-1));
}
itemLayout.setId(position);
return itemLayout;
}
}
#Override
protected void onListItemClick(ListView l, View v, int position, long id) {
super.onListItemClick(l, v, position, id);
if (position == 0) {
startActivity(prepareIntent(AShowPregnancy.class, 0));
} else {
showPregnancy(position-1);
}
}
void showPregnancy(int pregId) {
startActivity(prepareIntent(AShowPregnancy.class, pregId));
}
void editPregnancy(int pregId) {
startActivity(prepareIntent(ANewPregnancy.class, pregId));
}
Intent prepareIntent(Class<?> className, int pregId) {
Intent i = new Intent(this, className);
if (pregId > 0) {
PregnanciesDbAdapter db = new PregnanciesDbAdapter(this);
db.open();
Pregnancy p = db.load(pregIds.get(pregId));
db.close();
i.putExtra(C.EXTRA_PREGNANCY, p);
}
return i;
}
}
Thanks for reading. Hope you can help.
Oh, god, again. I found out myself how to do it, and it was easier than easy.
AdapterContextMenuInfo info = (AdapterContextMenuInfo) menuInfo;
// info.position is the position in the ListView
I hate myself :)