Please find the code sample below:
public class Abc extends Activity implements OnClickListener{
private ListView displayList;
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.mainlayout);
displayList =(ListView)findViewById(R.id.addressbooklistview); addressbookAdapter = new CustomListAdapter(this,addressbookList); displayList.setAdapter(addressbookAdapter);
registerForContextMenu(displayList);
}
@Override public void onCreateContextMenu(ContextMenu menu, View v,ContextMenuInfo menuInfo) { Log.e("", "Entered Context Menu"); }
public void onClick(View v) {
Log.e("", "Click Detected"); }
}
I am not able to invoke the context menu on long press. Please let me know any solution for the same.