I am sort of new to Android since I've done only some basic applications, but I'm more familiar with Java. I've been working on an application which should provide LoginActivity with two attributes that generate one Pair connection (IP address and port) at the top of the screen and a ListView of all already known connections (which were occasionally used before) right under the button "Connect".
My question is, how to implement some actions like add/edit/delete etc. when holding on a finger little longer on certain item in the ListView? How to make some menu for modification/deletion of already known connections?
Here's the code that I already got for the ListView:
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
super.onCreateContextMenu(menu, v, menuInfo);
if (v.getId()==R.id.list_view) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.menu_list, menu);
}
}
@Override
public boolean onContextItemSelected(MenuItem item) {
AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo();
switch(item.getItemId()) {
case R.id.edit:
//implement here
return true;
case R.id.delete:
//implement here
default:
return super.onContextItemSelected(item);
}
}