mardi 4 août 2015

How to get database attribute of selected ListView item on context menu selected?

I have a ListView populated with data from an object Schedule. Schedule comprises of scheduleId, scheduleTime, scheduleDate, scheduleName. My ListView adapter shows the scheduleTime and scheduleName. onContextItemSelected, an Edit option comes up and user on select, will be taken to activity EditScheduleActivity

 @Override
public  boolean onContextItemSelected(MenuItem item){

    if (item.getTitle() == "Edit"){
        Intent editActivity = new Intent(ViewTodayActivity.this, EditScheduleActivity.class);

        startActivity(editActivity);
    }
    return super.onContextItemSelected(item);
}

How will I be able to retrieve the scheduleID of the selected listview item, and then pass it in the intent to the next activity?

Aucun commentaire:

Enregistrer un commentaire