antoinedelia antoinedelia - 1 year ago 80
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() {
public void onItemClick() {}

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

listview.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
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 Source

Try this

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

    return true; //<-- this should be TRUE, not FALSE   
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download