Category : android-fragments

so I have bottomNavigationView that holds tabs and navigates to fragments using setOnNavigationItemSelectedListener() in one of the fragments I need to display google maps, but I’m getting this error: java.lang.NullPointerException: Attempt to invoke virtual method ‘void com.google.android.gms.maps.SupportMapFragment.getMapAsync (com.google.android.gms.maps.OnMapReadyCallback)’ on a null object reference even though I initialized SupportMapFragment right above the error line getMapAsync() like ..

Read more

Forgive me if this sounds absurd. Here is the scenario, I have one activityViewModel that share communication between a screen fragment and a bottom sheet fragment. A bottom sheet fragment is used to select any payment card.Selecting a card from the bottom sheet leads to, selected card info will be displayed on the screen fragment: ..

Read more

To enable data binding, I added to the build.gradle file: android { … buildFeatures { dataBinding true } } In my fragment, I added: private var _binding: WebViewFragmentBinding? = null private val binding get() = _binding!! override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { _binding = WebViewFragmentBinding.inflate(inflater, container, false) return binding.root } This ..

Read more

error: cannot find symbol variable fragment_container when I use this code holder.post_image.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { SharedPreferences.Editor editor = context.getSharedPreferences("PREFS", Context.MODE_PRIVATE).edit(); editor.putString("postid", postModel.getPostid()); editor.apply(); ((FragmentActivity)context).getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new PostDetailFragment()).commit(); } }); I got the this error. error: cannot find symbol ((FragmentActivity)context).getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new PostDetailFragment()).commit(); Why I cannot using this method? Source: Android..

Read more

I am trying to get the data using asynctaskloader and display the images in a fragment using recyclerview. Previously i did this, then i did not get the error.I am not sure why this is happening. currently i am getting this error: E/RecyclerView: No adapter attached; skipping layout Fragment classs: import static android.content.Context.INPUT_METHOD_SERVICE; public class ..

Read more

import android.content.Context import android.content.SharedPreferences import android.os.Handler import androidx.navigation.fragment.findNavController import com.greenhcm.android.R import com.greenhcm.android.common.base.BaseFragment import com.greenhcm.android.common.profile.CMProfile import org.koin.android.ext.android.inject class SplashFragment : BaseFragment() { private val cCMProfile: CMProfile by inject() override val layoutId = R.layout.fragment_splash override fun setupData() { } override fun setupView() { Handler().postDelayed({ view?.post { greenHCMProfile.getUser()?.let { findNavController().navigate(SplashFragmentDirections.navigateToDashboard()) } ?: findNavController().navigate(SplashFragmentDirections.navigateToOnboarding()) } }, 2000) } } ..

Read more

I need help here. So I’ve been tinkering with android studio and my app crashes everytime I type something in a textfield using onTextChanged and it prints this error in logcat java.lang.ArrayIndexOutOfBoundsException: length=0; index=-1. How do I fix it? Thanks in advance. Here’s my NotesFragment.java: package com.example.reminderapp; import android.content.Intent; import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; ..

Read more