Code example for ListFragment

Methods: onCreateContextMenu

0
	} 
 
	@Override 
	public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo)
	{ 
		super.onCreateContextMenu(menu, v, menuInfo);
		menu.add(0, 0, 0, "复制号码");
		menu.add(0, 1, 1, "复制内容");
	} 
 
	@Override 
	public boolean onContextItemSelected(MenuItem item)
	{ 
		log("itemid:" + item.getItemId());
		AdapterContextMenuInfo menuInfo = (AdapterContextMenuInfo) item.getMenuInfo();
		int position = menuInfo.position;
		log("position:" + position);
		SimpleCursorAdapter adapter = (SimpleCursorAdapter) getListAdapter();
		Cursor cursor = adapter.getCursor();
		cursor.moveToPosition(position);
Experience pair programming with AI  Get Codota for Java