@Override public void onListItemClick(ListView listView, View view, int position, long id) { super.onListItemClick(listView, view, position, id); // Notify the active callbacks interface (the activity, if the // fragment is attached to one) that an item has been selected. Receta receta = (Receta) listView.getAdapter().getItem(position); Toast.makeText(getContext(), receta.getNombre(), Toast.LENGTH_LONG).show(); mCallbacks.onItemSelected(receta); }
/** * Callback method from {@link RecetaListFragment.Callbacks} indicating that the item with the * given ID was selected. */ @Override public void onItemSelected(Receta receta) { if (mTwoPane) { // In two-pane mode, show the detail view in this activity by // adding or replacing the detail fragment using a // fragment transaction. Bundle arguments = new Bundle(); arguments.putSerializable(RecetaDetailFragment.ARG_ITEM_ID, receta); RecetaDetailFragment fragment = new RecetaDetailFragment(); fragment.setArguments(arguments); getSupportFragmentManager() .beginTransaction() .replace(R.id.receta_detail_container, fragment) .commit(); } else { // In single-pane mode, simply start the detail activity // for the selected item ID. Intent detailIntent = new Intent(this, RecetaDetailActivity.class); Log.w("Recetas", receta.getNombre()); detailIntent.putExtra(RecetaDetailFragment.ARG_ITEM_ID, receta); startActivity(detailIntent); } }