I have this list, which is where I want to pass the item through the popup menu
And the code is this:
public class route1 extends Activity {
ListView listaruta;
List<String> list = new ArrayList<String>();
ArrayAdapter<String> adapter;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.ruta1);
listaruta = (ListView) findViewById(R.id.listview_ruta1);
list.add("Monitor");
list.add("Keyboard");
list.add("Mouse");
list.add("Mother Board");
list.add("Hard Disk");
adapter = new ArrayAdapter<String>(this, android.R.layout.simple_expandable_list_item_1, list);
listaruta.setAdapter(adapter);
registerForContextMenu(listaruta);
}
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
super.onCreateContextMenu(menu, v, menuInfo);
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.main_context_menu, menu);
}
@Override
public boolean onContextItemSelected(MenuItem item) {
AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo();
switch (item.getItemId())
{
case R.id.delete_id:
list.remove(info.position);
adapter.notifyDataSetChanged();
return true;
default:
return super.onContextItemSelected(item);
}
}
}
Now my question is: What should I put in case to achieve adding the desired item to the other listview?
Here is the pop menu and its code
Thank you.