I'm making a basic application to study Android. Starting with that, I'm making a memo application, and I'm using listview in the fragment to show the list of notes.
Here, the notes in the list fragment are set to a fixed size. And if you click on the memo item, you'll see a replacement of another fragment (I forgot to put the name) as shown in the picture.
The next problem is, I have to click Memo 1 and then go back to the list fragment, so how can I go back?
The method you've just used is in a fragment that shows details: getActivity().getSupportFragmentManager().beginTransaction().replace(~~~!~!~!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ I succeeded in changing it like this, but I can't see the existing notes...<
Also, if you click Memo 1 in the list fragment, the details will be replaced with another fragment Click on the item and replace the other fragment with activity. The listener has been registered and processed.
android listview fragment
You said you succeeded with getActivity().getSupportFragmentManager().beginTransaction().replace(). Please call addToBackStack("tag name"); and
ex) getActivity().getSupportFragmentManager().beginTransaction().addToBackStack("").replace()...
If you override the onBackPressed called when the Android Backkey is pressed in the activity and call popBackStack();
as shown below, the previous fragment will be called.
@Override
public void onBackPressed() {
fragmentManager.popBackStack();
}
© 2024 OneMinuteCode. All rights reserved.