-
-
Save parzibyte/26e7b5570ef7c8628f91f2e8262a9357 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class GastosFragment extends Fragment { | |
private List<Gasto> gastos; // Variable de instancia | |
@Override | |
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { | |
GastosController gastosController = new GastosController(getActivity()); | |
gastos = gastosController.obtenerGastos(); // Aquí definimos lo que será gastos | |
AdaptadorGastos adaptadorGastos = new AdaptadorGastos(gastos); | |
recyclerView.addOnItemTouchListener(new RecyclerTouchListener(getActivity(), recyclerView, new RecyclerTouchListener.ClickListener() { | |
// Esta es una "inner class" | |
@Override | |
public void onLongClick(View view, int position) { | |
// Y ahora sí podemos acceder a gastos ;) | |
Gasto gasto = gastos.get(position); | |
} | |
})); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment