Вот мое решение:
public class SelectRecipeListener implements AdapterView.OnItemClickListener,
View.OnClickListener{
private Context currentContext;
private boolean storeAsLastViewed;
public SelectRecipeListener(Context context, boolean store) {
currentContext = context;
storeAsLastViewed = store;
}
public void onItemClick(AdapterView<?> parent, View view, int position,
long id) {
execute((String) view.getTag());
}
public void onClick(View v) {
execute((String) v.getTag());
}
private void execute(String id) {
Intent intent = new Intent(currentContext, RecipeTabHost.class);
intent.putExtra(currentContext.getResources().getString(
R.string.recipe_id_transition_key), id);
intent.putExtra(currentContext.getResources().getString(
R.string.last_recipe_id_storing_key), storeAsLastViewed);
currentContext.startActivity(intent);
}
}