Skip to content
Advertisement

Tag: android-fragments

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

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 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:

Advertisement