antoinedelia antoinedelia - 6 months ago 21
Java Question

On hold event trigger the on click event

I have a ListView displayed on my screen.

When I click on an item (using setOnItemClickListener), you can rename it.

listview.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick() {}


When I hold on an item (using setOnItemLongClickListener), you can delete it.

listview.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
@Override
public boolean onItemLongClick() {}


However, when i hold on an item, it displays the "rename" window and the "delete" window, as if both were triggered.

Any idea on how to prevent this?

Thanks a lot

Answer

Try this

@Override
public boolean onItemLongClick(AdapterView<?> parent, View view,
            int position, long id) {

    return true; //<-- this should be TRUE, not FALSE   
}
Comments