在我的应用程序中,我有一个扩展 ListActivity 并使用 ListView 的类。我的 onListItemClick 方法就是不想工作。在方法内部,它必须确定被点击的项目是锻炼 A 还是锻炼 B。下面是代码:
@Override
protected void onListItemClick(ListView l, View v, int position, long id) {
super.onListItemClick(l, v, position, id);
Long rowId = id;
Cursor cursor = mDbHelper.fetchNote(rowId);
String activity = cursor.getString(cursor.getColumnIndexOrThrow(StrongDbAdapter.WORKOUT_STATE));
if(activity == "Workout A"){
workoutAA = true;
}else if(activity == "Workout B"){
workoutAA = false;
}
if(workoutAA == true){
Intent i = new Intent(this, WorkoutEditA.class);
i.putExtra(StrongDbAdapter.KEY_ROWID, id);
startActivityForResult(i, ACTIVITY_EDIT);
}else if(activity == "Workout B"){
Intent i = new Intent(this, WorkoutEditB.class);
i.putExtra(StrongDbAdapter.KEY_ROWID, id);
startActivityForResult(i, ACTIVITY_EDIT);
}
}