Questions tagged [fragment-oncreateview]
45 questions
1
vote
2 answers
Fragment onCreateView getting called multiple time so that new instance of fragment is created every time
I am trying to add the fragments on page change of view pager. but every time when i scroll the view pager, new instant of fragment is created.
public void initializeViewPager(int currentPage, String selectedCardNumber) {
currentPosition =…

mdDroid
- 3,135
- 2
- 22
- 34
1
vote
1 answer
Fragment within fragment not setting class variable on second call
I have a TripDetailFragment that contains a TripMemberFragment and a TripPhotosFragment. Inside the TripMemberFragment, I have a private instance variable Trip trip. This variable correctly gets set on the first call of a TripDetailFragment.…

Kathy
- 41
- 1
- 1
- 6
1
vote
1 answer
Fragment's on CreateView is not called when using ViewPager
I'm developing an Android Application where I have a ViewPager in my MainActivity, consisting of 3 Fragments.
The Problem is as follows, when I swipe to the 3rd fragment, and get back to the 1st one, onCreateView of fragment 1 is called which is…

Ahmed Khairy
- 145
- 2
- 16
1
vote
1 answer
How to avoid the layout inflation each time a fragment transaction is committed?
I am using fragments to design my screen.When I navigate back to another fragment (from the back stack), the onCreateView(...) method gets called each time even if the fragment has already been created.How to avoid that the method onCreateView(...)…

HiddenDroid
- 1,440
- 4
- 14
- 27
0
votes
0 answers
Is there a way to refresh a fragment in the onResume method?
My favourites fragment does not display the data given correctly unless the onCreateView function is called. This means that the fragment needs to be deleted and created again. Is there a way to appropriately refresh the fragment in the onResume…

lunderhill
- 3
- 1
0
votes
1 answer
Android - Restore Programmatically Created Views
I am currently designing an app that helps you manage recipes. When you create a recipe, a series of EditText views are created programmatically when you click an 'add' button. You can make as many steps/EditText lines as you want, so it is not a…

Connor Smith
- 75
- 7
0
votes
1 answer
OnCreateView is called but fragment is not visible
I used logs to see if onCreateView and onViewCreated are called. Everything seems fine on that side. However, for some reason, it is not showing the layout of the fragment. Nothing is visible except the main_actvity layout.
P.S. please don't mind…
0
votes
1 answer
Fragment's onCreateView() is not being called
I am creating an instance of my fragment and then trying to call one of it's methods but a variable needs to be instantiated in onCreateView() before the method can be called without throwing a NullPointerException.
Here is part of my…

Dylon Jaynes
- 166
- 11
0
votes
1 answer
How to use hasOptionsMenu() in Android?
My code shows an error with the text:
"Fragment.hasOptionsMenu can only be called from within the same library group prefix (referenced groupId=androidx.fragment with prefix androidx from groupId=Personal Pocket Dictionary"
I've imported the library…

Hamid Ebadi
- 405
- 3
- 4
0
votes
1 answer
How to load data into android list fragment async?
I have a fragment, with only a list view. I am loading the favourites from my database like below. How do I load them async? Currently I am forced to make the async method synchronised while loading the view. I would like it so the view loads, then…

Colton Scottie
- 807
- 1
- 8
- 22
0
votes
1 answer
GoogleMaps in FragmentActivity AndroidStudio
I'm developing an app using Android sdk version 29. I want to add Google Maps in one of my Fragments Activity but its not working and i couldnt fix it.
fradment_map.xml

Jhumildes
- 3
- 1
0
votes
1 answer
Get the view of a Fragment outside of OnCreateView() - View is null
Inside onCreateView i can instance View with the inflate, in this way:
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this…

mmarcoso
- 1
- 2
0
votes
0 answers
How to access multiple views in a fragment in android?
HomeFragment.java:
public class HomeFragment extends Fragment {
FirebaseAuth fAuth;
String userId;
Button logout;
FirebaseFirestore fStore;
EditText name,no,mail;
public HomeFragment() {
}
public static…
0
votes
1 answer
No Adapter Attached, Skipping Layout on Fragment
I've tried a few different ways of fixing this, but it just doesn't seem to want to work. I have attached the fragment involved. The recyclerview works when I use the search function; However, when I first load the page, I get the error…

AndroidProButNo
- 31
- 1
- 7
0
votes
0 answers
Parent fragment's onCreateView is called after child fragments onCreateView
I have a ParentFragment and a ChildFragment that extends from it. I placed a log in onCreateView method of both fragments. But ParentFragment's onCreateView is being called last.
However, the same parent-child relationship between activities is…

Azizjon Kholmatov
- 1,136
- 1
- 13
- 26