Вот мое решение:
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);
}
}
Не могли бы вы быть более конкретными с классом обертки? – Gratzi
yes, Напишите класс MyButton, который расширяет Button и MyList, который расширяет List и позволяет им внедрить интерфейс MyInterface, который имеет метод, называемый widgetTaped (...), теперь как в MyList, так и в MyList, когда вызываются их соответствующие кликеры, вызовите метод widgetTaped(). Есть много других способов сделать это тоже ... пожалуйста, изучите – amithgc
Спасибо за подсказки. Я создал слушателя, который реализует прослушиватель списка и прослушиватель представления, и который имеет метод, называемый в обоих методах слушателей. – Gratzi