Click and hold in ListView [duplicate]

1

How do I program to click and hold down a method other than just a normal click in the ListView?

I would like tips, tutorials something that can help me.

@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            Intent intent = new Intent(getActivity().getBaseContext(), inalcancaveis_tela.class);
            startActivity(intent);
}

I call this method in onCreateView

list.setOnItemClickListener(this);

OBS: to using extends Fragment

    
asked by anonymous 16.07.2014 / 15:32

1 answer

3

Make your class implement the event to long click implements OnItemLongClickListener And use the onItemLongClick method as below:

@Override
public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
    Intent intent = new Intent(getActivity().getBaseContext(), inalcancaveis_tela.class);
    startActivity(intent);
}

no onCreate of your class you should now call this method to register your event:

list.setOnItemLongClickListener(this);

Abs

    
16.07.2014 / 15:43