I have a listview on my MainActivity. I have set up an onLongClickListener to open a MapsActivity when any of the listview items are long pressed.
How can I copy the contents of the listview item that is pressed to the MapsActivity?
How can I copy one of the fields (e.g. an address field) from the listview item that is long pressed to the MapsActivity? Below is the code in the listener with an intent filter to open the MapsActivity.
list.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
@Override
public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
//Open Maps Activity
Intent k = new Intent(MainActivity.this, MapsActivity.class);
Calendar c = (Calendar)parent.getItemAtPosition(position);
startActivity(k);
return true;
Any help is appreciated!
Use setonItemSelected listener this gives you the position of the selected item you can then get data corresponding to that position and display it