I have problem with positioning FAB inside Fragment. FAB is on the top left, but I need it on the bottom right. What I have wrong? Answer as I have read , FAB doesn’t work with relative layout very well and you should use Coordinator Layout instead. first include its dependency in build.gradle(Module:app) then declare Coordinator Layout like this instead
Tag: android-fragments
Adding a ListView in a Fragment
I want to add a ListView to a Fragment. I created a FrameLayout in my activity_main.xml and then created 3 fragments (Home, Tags, Settings). What I did was create a bottom navigation view and created 3 frame layouts for the mentioned fragments. I searched the whole web on how to add a ListView to a Fragment, but whatever code they
How to implement “favourite” button feature (like favourite recipe/food) and display on another list in another fragment
I want to have a feature that when the user clicked the button on a certain row, it will add the row to another list which is called favorite list. Currently i have created database that also include favourite status. I already tried to start with creating a button that when its clicked it will change the fav status. Im
Update recycler view when a item is deleted on onBindViewHolder listener
I’m having a problem, that maybe we can solve it and help the community. I have made an Adapter for my RecyclerView and I have created a listener for the constraint layout in order to remove one element of the list. As you can see in the code the delete message works well but I don’t know how to update
Java OnClickListener not working in Android Fragment
I am trying to add a simple click on a button in a Fragment but the event is ignored. This is the code: I don’t know what is wrong in the code? Answer ok I have fixed this by using FragmentManager like :- for more details:- go to Android Studio – Fragment onClickListener not working
How can i listen for Fragment change in my Activity?
I have an Activity which based on intent opens Fragment1 or Fragment2. From the activity after some stuff are done if the user is in Fragment1 i replace the fragment to Fragment2 and that can be done even from the Fragment1 diretly. For each Fragment i have to change items in my BottomAppBar, till i’m in Activity i have no
Fragment display different content
Can I make a Fragment to display different content depending on what was selected in the previous screen. For example: I create Fragment with ImageView and TextView. In MainActivity I click Button1 and the Fragment opens and shows some content, and if I click Button2 the same Fragment opens but different content is displayed. Is it possible to do this?
When calling a method between fragments, must it go through an activity?
I want to open a dialog fragment from A fragment, and pass data to A fragment when the dialog fragment ends. To do this, I defined an interface in the dialog fragment and implemented it in the A fragment. The result was that the listener was null. This is because onAttach() used context and context meant activity. The activity did
How do I check if a field in another activity was filled? [closed]
Each user has its profile that is stored in a XML file linked to a Java class. But not necessarily they access this profile when they use the App, because they may just use the app without editing its …
when I click on the button the app crashes
Here the error: java code: xml file: when I click on the button the app crashes Using tabbed activity from android studio example whit legacy android studio libraries Any help is welcome Answer You can not use android:onClick attribute in fragment layout unless you create it in the activity class, not the fragment class. In your case: Here the error: