Questions tagged fragment

Explore the latest questions and answers asked by our top developers.

Is Google Document proposed way of Fragment Creation conflicting with ViewBinding of Fragment?

In Google Documentation, we are guided to create Fragment using code as below, where we can pass the layout id through the constructor class ExampleFragment : Fragment(R.layout.example_fragment) At the same time, we know that we are recommended to use ViewBinding to access the view components. As per the Google Document private var _binding: ResultProfileBinding? = […]

By Elye
Published
Categorized as android, android-viewbinding, fragment

Navigation Component not handling system back button by default in Fragment

I have to implement Navigation Component in a Fragment(MainFragment) and all other fragment inside the navigation component. I simply want to handle system back press on Navigation that’s implemented in MainFragment I initially added my MainFragment to MainActivity like if (savedInstanceState == null) { val bundle = bundleOf("sourceType" to 0) supportFragmentManager.commit { setReorderingAllowed(true) add<MainFragment>(R.id.fragment_container_view, args […]

By Taimoor Khan
Published
Categorized as android, fragment, kotlin, navigation

How do I switch between fragments using the ExpandableBottomBar menu items?

The app starts normal with no fragment and when I click on any of the items in the bottom menu bar the app crashes suddenly. I have used the ExpandableBottomBar github repository to create this bottom bar menu. If you need any more info I will provide. I need help as this is my first […]

My app keeps crashing when i try to search for users

My app always crashes when i try to search for users. logcat directed me to a line in my search fragment but i do not know exactly what to do private fun searchUser(input: String) { val query = FirebaseDatabase.getInstance().reference .child("Users") .orderByChild("fullname") .startAt(input) .endAt(input + "uf8ff") query.addValueEventListener(object: ValueEventListener { @SuppressLint("NotifyDataSetChanged") override fun onDataChange(dataSnapshot: DataSnapshot) { mUser?.clear() […]

By Ali Apochi
Published
Categorized as android, firebase, fragment, kotlin, search

When Admob ads are implemented in host activity, how can a child fragment be notified of the callback result?

Hi to all and happy/healthy new year! So, I have an activity which can add/replace 3 fragments in a container layout. Each fragment can request an Admob rewarded ad for giving access to it’s content (on button click inside the fragment). For now, I have implemented ad requests and callbacks in fragments (same implementation 3 […]

By devkos
Published
Categorized as admob, android, callback, fragment, java

App Closes When Directing Towards A Fragment On Button Click

So I have a Fragment known as LoginHomeFragment which contains buttons to 2 fragments of my app, RegisterFragment & LoginFragment The button click for RegisterFragment works perfectly But when the LoginFragment button is clicked, the app automatically closes. This is the same when I redirect to the LoginFragment from my RegisterFragment. The code for my […]

By Mahaboss
Published
Categorized as android, authentication, fragment, kotlin, xml

Using Recyclerview in a fragment

I’m trying to output the Recycler view in a fragment, but after launching I get a blank screen. Please tell me how it can be fixed? I get the data from the URL (XML string), then parse it and write it to the ArrayList. I apologize for my English. BusinessFragment.java (In the fragment, I use […]

By
Published
Categorized as android, android-recyclerview, fragment

Reload Fragment after popBackStack

I need reload fragment after this process Go from Fragment A to Fragment B and go from Fragment B to Fragment C, then do the registration process, and after the registration is correct, popBackStack Fragment A and my Fragment A will be reloaded. My main problem is that Fragment A is not reloaded Please help […]

By asghar hosseini
Published
Categorized as android, android-fragment-manager, fragment

Using Recyclerview in fragment

I need to output the Recyclerview in a fragment. How can this be done, please tell me? It works with Activity. I apologize for my English. MainActivity.java: (a second stream is used to get an xml string, then parsing takes place (there is actually more data)) ”’ public class MainActivity extends AppCompatActivity { ArrayList<String> title […]

By
Published
Categorized as android, android-recyclerview, fragment

how use setOnclickListener and observe for result in fragment?

I have a login page that is implemented in the fragment and this fragment is related to one of the BottomNavigation items. But in this part -> loginViewModel.loginMessage.observe From the second time onwards when I click on the profile item in BottomNavigation runs continuously without entering the email and password and always gives an error […]

By reza fathi921
Published
Categorized as android, fragment, kotlin, mvvm, observable
1 2 3 4 75

Still Have Questions?


Our dedicated development team is here for you!

We can help you find answers to your question for as low as 5$.

Contact Us
faq