Questions tagged [fragment-oncreateview]
45 questions
6
votes
2 answers
Fragment Recyclerview onCreateView, onViewCreated or onActivityCreated?
Should i initialize my recyclerview in onCreateView, onViewCreated or onActivityCreated?
What's the difference between those 3, i searched for explanations but some people say to use onCreateView and some say to use onViewCreated or…

Vince VD
- 1,506
- 17
- 38
4
votes
5 answers
Android(Fragment) - Is it recommended to initialize a view object inside onActivityCreated method?
View variables of fragments can be initialised in onCreateViewmethod in this way.Here the TextView is inside the fragment.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view =…
user5949092
3
votes
2 answers
Android Fragment with ViewPagers oncreateView Called in Wrong Fragment
I have a main activity which shows 3 fragments inside View Pagers with tabs.
mainActivity.java
public class mainActivity extends AppCompatActivity {
globalVariableActivity variable = new globalVariableActivity();
private APIService…

J_LDAP
- 153
- 1
- 6
3
votes
4 answers
Can I use OnCreateView with the Activity or is only used with fragments?
If OnCreateView is only for fragments, what would be for Activity?
I tried OnCreate() and I cannot make it work
In the first Override I have problems, and in the last Overide it also give me an error for the OncreateView.
I have read about…

Javi
- 41
- 1
- 7
3
votes
0 answers
View is null in onCreateView android
I've written a custom view for displaying events in a 24 hour vertical scroll timeline.
In the onCreateView method in the fragment that inflates this view, I am inflating the view and then trying to set callbacks which are exposed by the view.…

Thomas Cook
- 4,371
- 2
- 25
- 42
2
votes
1 answer
Fragments without onCreateView
recently i saw some articles about inflating the fragment layout directly from the Fragment()
class ExampleFragment: Fragment(R.layout.example_fragment)
does this stand only for fragments that dont hold any data and interaction, when should we use…

ardritkrasniqi
- 739
- 5
- 13
2
votes
1 answer
Android - PageView in new BottomNavigationBar - prevent reload fragments
In my StartActivity the BottomNavigationBar Listener has the following setup:
private GuideFragment guideFragment = new GuideFragment();
private MapFragment mapFragment = new MapFragment();
private MoreFragment moreFragment = new…

Tobias Alt
- 453
- 1
- 3
- 11
2
votes
0 answers
Single Activity app, Fragment onCreateView called again after detached attached
Now that Google has released the BottomNavigationView, the designers from my work wants me to have a bottom menu persisted on all Views in the app.
That means I have to create a single Activity app. But it seems that the Android Framework is not…

Kasper Finne Nielsen
- 2,086
- 2
- 17
- 28
2
votes
1 answer
Android CommitNow Does Not call onCreateView from onCreate
Create app with a Fragment containing a Button id=button
In
@Override
protected void onStart() {
super.onStart();
getSupportFragmentManager()
.beginTransaction()
.add(R.id.activity_main, new…

Mike James
- 749
- 6
- 9
1
vote
2 answers
How to open a different activity on recyclerView in fragment?
I am using a recyclerView to show my listItems in the home fragment. But I have been stuck on how to open a different activity when items are clicked. How can I do for the next steps? Could you please help me to solve the issue? I would appreciate…

Wee Kiat Lim
- 43
- 7
1
vote
1 answer
Button of destroyed fragment still visible
I've got a simple fragment:
public class DriverListFragment extends Fragment {
public DriverListFragment() {
}
public static DriverListFragment newInstance(String param1, String param2) {
return new DriverListFragment();
…

Savan Luffy
- 440
- 3
- 12
1
vote
3 answers
Kotlin ViewModel onchange gets called multiple times when back from Fragment (using Lifecycle implementation)
I am working with the MVVM architecture.
The code
When I click a button, the method orderAction is triggered. It just posts an enum (further logic will be added).
ViewModel
class DashboardUserViewModel(application: Application) :…

Link 88
- 553
- 8
- 27
1
vote
2 answers
MapBox in a fragment once I press back button also having a problem with permissionsManager.requestLocationPermissions(this)
I am new to Java and Android Studios. I am currently trying to put the MapBox map into a fragment, and obtain my device location. It kind of worked and the map launched in a fragment as well my location was found, but once I press back button on my…

S B
- 9
- 6
1
vote
0 answers
Android Studio OnCreateView never used fragment
I'm making an app based on this Youtube video and I'm having problems with the whole thing despite copying everything 1:1, haven't missed a thing. So, my problem is, that at the 15:30 point, the poster compiles the app and after clicking into the…

adr
- 15
- 6
1
vote
1 answer
Android: inflate layout into fragment but onCreate don't start
I'm trying to use Fragments in android.
So in the method "getItem()" into the class "TabAdapter", I have:
public Fragment getItem(int position) {
switch (position) {
case 0:
Browse tab1 = new Browse();
…

Re De Pasquale
- 90
- 9