Questions tagged [fragment-oncreateview]
45 questions
0
votes
1 answer
onCreateView pager adapter
Attempt to invoke virtual method 'void androidx.viewpager.widget.ViewPager.setAdapter(androidx.viewpager.widget.PagerAdapter)' on a null object reference
I'm trying to implement sliding tab layout using android material design. But it gives me…

tommy
- 31
- 4
0
votes
2 answers
How to create Fragment's elements when app starts without recreating them
I use four fragment in mainactivity and each has it's class with mainactivity class.
I have elements in fragment1 class, when I create them inside onCreateView method they are creating each time when I open the fragment.
I tried to create elements…

Melih
- 23
- 10
0
votes
1 answer
Fragment onCreateView Calls Again when I call fragment function from Main Activity?
Actually my problem is I want to send string from Main Activity to My Fragment on button clickListner but when I call fragment function from Main activity, onCreateView of fragment calls again and everything Initialize again. Please guide me how can…

MajidTiger
- 17
- 5
0
votes
2 answers
how to force method execution to finish before returning the fragment view
in my code lets say that I want to display some string in a fragment, and method getPlayerList takes 2 seconds(data from API), but method 'onCreateView' is returning the view before 'getPlayerList' finishing its execution.
I tried to implement it in…

Cocodile
- 11
- 6
0
votes
1 answer
Fragment onCreateView etc. methods don't get called
Inside my MainActivity.java class I have a starting fragment called MainScreenFragment.java which works as expected. However, when the user clicks on the 2nd menu item in my drawer-layout I replace it with another fragment called…

Stelios Papamichail
- 955
- 2
- 19
- 57
0
votes
1 answer
Updating a Fragment View
I need to update a Fragment View so that I can update my Recycle View as values come in from my database in real time. I currently do this in the OnCreateView method but this does not allow me to update when the tabs are switched.
public class…

david sherrier
- 11
- 4
0
votes
4 answers
onCreateView not called tab fragment
I currently have this tab view which I followed from this tutorial. Everything works fine until I noticed that the onCreateView is not called on any of the tab. I've looked around here and there for solution but I still can't solve.
Here is my…

azriebakri
- 1,131
- 2
- 11
- 36
0
votes
2 answers
Perform network operations before onCreateView
In my application fragment i am setting values for arrayList by loading data for server in onCreate() method and then i want to display that data into listView with the help of adapter but when i run my program it executes onCreateView() first…

user7661245
- 19
- 4
-1
votes
1 answer
How to define a callback for when an AsyncTask completes
I have an Android fragment which requests a web page using an AsyncTask and retrieves the page title which should be displayed in a TextView. I invoke the AsyncTask in onCreateView().
The problem is there is a noticiable delay before the AsyncTask…

lschmid
- 183
- 1
- 1
- 11
-1
votes
1 answer
DialogFragment: "lateinit property binding has not been initialized" in onCreateDialog(), whereas binding is initiated in onViewCerated()
kotlin.UninitializedPropertyAccessException: lateinit property binding has not been initialized
at…

Alex Rodionow
- 247
- 3
- 13
-1
votes
1 answer
Where do lifecycle methods, and other methods, get their parameter values?
In the following Android lifecycle method:
@Override
public View onCreateView(
LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = super.onCreateView(inflater, container,…

FernandoH-G
- 74
- 11
-1
votes
1 answer
Use Async Task in oncreateview
Is there a way to overwrite the "week_kg" variable with the async task in the oncreateview method?
The async task overwrites the variable, but the View is already created and doesn't contain the new value.
It's a Rest Communications with a Node.js…

Aaron
- 3
- 3
-1
votes
1 answer
How to manage to start fragment `onCreateView()` after data is loaded form the internet
I have 3 Fragments inside a ViewPager. I call an API in onCreate() of the first Fragment which returns JSON data (second and third Fragments are empty).
The problem is that onCreateView() is always executed before getting data from API, so I need to…

Mehrdad Salimi
- 1,400
- 4
- 16
- 31
-1
votes
2 answers
Local Variable in Fragment class
I have a fragment where I want to display values from a List, so I get it like this in Activity Recipe Detail
IngredientsFragment ingredientsFrag = new IngredientsFragment();
ingredientsFrag.setPosition(position);
…

Lemuel Ogbunude
- 184
- 3
- 16
-2
votes
4 answers
How to disable a button in onCreate method with if statment
I have a problem, I want to disable a button in onCreate method, please share the way of disabling any button at runtime in onCreate method.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
…