0

I have a list view that with custom Array adapter:

lstVeicoli = (ListView) findViewById(R.id.lstVeicoli);
adapter = new VeicoloAdapter(VeicoliActivity.this, R.layout.row_veicolo, new ArrayList<Veicolo>());
lstVeicoli.setAdapter(adapter);

The code of my adapter is:

public class VeicoloAdapter extends ArrayAdapter<Veicolo> {

private Context ctx;

@Override
public View getView(int position, View v, ViewGroup parent) {

    // Recuperiamo l'oggetto che dobbiamo inserire a questa posizione
    final Veicolo veicolo = getItem(position);

    v.setOnLongClickListener(new OnLongClickListener() {

        @Override
        public boolean onLongClick(View v) {
            // TODO Auto-generated method stub
            return true;
        }

    });

    return v;
}

How can I create and show a context menu in onLongClickListener (I have also onClickListener but I didn't write for save space)??

aletede91
  • 1,137
  • 2
  • 16
  • 30
  • For creating a context menu, Google has a nice guide on all the steps required for creating menus [located here](http://developer.android.com/guide/topics/ui/menus.html#context-menu). – dsrees Mar 26 '15 at 13:30
  • Thanks but I need to use context menu inside an arrayadapter not in my activity – aletede91 Mar 26 '15 at 13:34
  • This post will help you figure it out: http://stackoverflow.com/questions/18632331/using-contextmenu-with-listview-in-android – arlistan Mar 26 '15 at 13:44
  • Checkout this: http://stackoverflow.com/questions/17207366/creating-a-menu-after-a-long-click-event-on-a-list-view – emiafe May 16 '17 at 08:08

0 Answers0