You could always use a context menu which does the same thing.
First of all register a listener on your ListView:
registerForContextMenu(myListView);
Set up your context menu options:
@Override
public void onCreateContextMenu(ContextMenu menu, View v,ContextMenuInfo menuInfo) {
super.onCreateContextMenu(menu, v, menuInfo);
if (v==myLIstView)
{
menu.setHeaderTitle("Optional title");
menu.add(0, v.getId(), 0,"Edit post");
menu.add(0, v.getId(), 0,"Delete post");
}
}
Capture and do something with the result:
@Override
public boolean onContextItemSelected(MenuItem item) {
// TODO Auto-generated method stub
AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();
long num= info.id;
if(item.getTitle()=="Edit post")
{
edit a post
}
else if(item.getTitle()=="Delete post"){
delete a post
}
}
return super.onContextItemSelected(item);
}