Create and Design a TabLayout with Fragments Android studio tutorial
Вставка
- Опубліковано 15 жов 2024
- It's been a long time since I uploaded a new video. I'm very sorry about that. It was really hard for me to find the time to make this tutorial. I hope you are all doing well and I wish a happy new year for everyone :)
In this video I will show you how to design and create a tablayout with fragments!
In this part I will show you how to design the light theme version of the tablayout in the second part we will design the dark one and maybe we will add icons to the tab. stay tuned!
if you enjoyed and learned something from my tutorials Please subscribe and like this video
-------------------------------------------------------------------------
Follow me On :
Google Plus : goo.gl/3nJik6
Instagram : goo.gl/tghvar
Github : goo.gl/QVn8np
My blog : goo.gl/1c5zut
--------------------------------------------------------------------------
Music Credits:
chill day by LAKEY INSPIRED
music link : goo.gl/ufSKkB
Android UI design can be a pain. You're one of only few channels that give out tutorial on great UX design and your channel is the best I've seen so far.
Thanks, man.
2nd week of working as an Android Dev and your tutorials really helped me. Thank you so much!
All his tutorials are so clean, the designs are immaculate ... I love this channel... Can't wait for more videos
Finally some fucking good channel with android programming tutorials, thanks man ;)
Kudos to everyone who followed this tutorial and figured it out. im going on my 3rd day and still havent figured out the last 1:30 minutes.
God bless you greatly.. the background music is worth it
You kind of saved my sanity... thx for the video!
Which tool did you use to showcase your work in the introduction?
Thanks for this tutorial.
I am a beginner Andriod developer and I am facing problem using the TabLayout in my project. Please help me out with this problem.
Thank you sir for this video.
A question: is-it possible to use the class ViewPagerAdapter for several tabbed Activities in the same app only by changing for each activity the too ArrayList of the fragments and the titles? I try but i don't succeed. Thank you.
Thanks for the video man for me it is working but I was wondering it is possible when the app is open the second tab is selected not the first or the third ?
I saw tons of video then I came urs man u saved me
hy. I want to parse data from activity to fragment tab. can you enplane how it work? I try several methods. but cant do it. plz help me..
nice work man!!
But can I change the image in the image view when i go to the next tab? I have seen some app changes the image when they swipe to new tab... Can i know which command or code will be required to do that... Thnku
Give me a short time I will look for the solution :)
Aws Rh sure... Take your time.. 🔥
bro can you send me the source code ?
tabLayout.addOnTabSelectedListener(new OnTabSelectedListener() {
@Override
public void onTabSelected(Tab tab) {
switch(tab.getPosition()) {
case 0: setimage 1;break;
case 1: setimage 2;break;
case 2: setimage 3;break;
....
}
}
+Sumeet Devilmakerzz i want to thank you for this idea :D it will give a nice ux interaction!
+Aws Rh anytime dude! thx for ur support and keep uploading such great UX video man! Ur the only channel who are giving great tutorials for good UX
keep up the good work
bro after two days i finally did it.... tysm man!! u gained a sub from me ily.
Thank you so much for the tutorial! It's really clear to understand for beginner like me:)
Hi, I can't use 'compile' in my build.gradle dependencies, instead it suggests me to use 'implementation'. But when I changed it to implementation, the app won't run and says 'Failed to resolve: com.android.support:appcompact-v7:25.3.1'. Can you help me with that? Thanks in advance.
Just stumbled upon this channel, for your videos +1 sub. You rock man!
thank you for your support
Great video, many thanks. However when I put a longer string in titles the font size reduces(in that string only). Please, do you know hot to prevent this?
my best buddy is back,,
with a bang,,
and of course we are still keeping a clean sheet on the score board,, hahahahahaha
lol Terry, your are the best my Friend 😂😂
Many thanks bro, may Allah give you more knowledge ...
:D
Hello ;
how can i open it. New fragment in the same area without leaving the tablayout when the button on the fragment is clicked.?..
great work.. but when i tab or scroll color is not changing white to black ??
Hey there i was wondering, my tablayout is not aligned under the image. Do you know maybe what it may be the cause?
you re a king, and awesome teacher. thanx very very thanx bro.
hi, can we slide appbar image too at the time of sliding tab layout
Great! exactly what I was looking for. Tablayout from empty. Thank you
Thanks man this was really helpful
@Aws Rh Thanks ! It worked for me !
Hey guys ! If you want to have icons for you TabLayout, then what you can do is create an int[ ] array of drawables in your MainActivity onCreate method.
For example :
TabLayout myTabLayout = findViewById(R.id.my_tab_layout);
int[ ] tabIcons = { R.drawable.tab_1_icon , R.drawable.tab_2_icon , R.drawable.tab_3_icon };
myTabLayout.getTabAt(0).setIcon(tabIcons[0]);
myTabLayout.getTabAt(1).setIcon(tabIcons[1]);
myTabLayout.getTabAt(2).setIcon(tabIcons[2]);
Hope it helpful to you !
Can you create custom tab like uc browser and chrome .....?????
Why when I inflate a layout, he loss the instance from firebase and not load the user information? But when I load just the layout, without tabs, it works :s
"the content are swipe cards, so its not appearing nothing when I load from inflate inside fragment"
Sir you always gives a unique design but why don't you explain the coding. Please explain the code too so that we can understand it much better than now. Please it's a request.
sry dude. before i make a video i assume that everyone have the basic of android, also im always trying to write a clean code, so anyone can understand it ,it take a long time to make this video and will take more if i add comments ... i cant do nothing for the moment
Aws Rh It's ok sir... But atleast some specific points plz try to do. It will be so helpful for everyone like the beginners like me.
alright my friend i will do my best
Thanks Dude!!This Tutorial Really Helped Me Out..Nice Work
When I run the project, the 3 different fragments won't display? :( Why is that? Pls. I need an answer :((
Thanks, very great tutorial. No errors
Hi, I tried your tutorial 3 times, but when I everytime run it on emulator or my phone, it crashed. Can you please help me? I observed there few automated changes in build.Gradle (app) file which are it is using support design library version 27 and the target sdk is also 27. Please help me regarding this.
Edit: Solved, It was issue with drawable image. We need to convert image for different dpis else it wont be suitable for different dpi devices.
i'm having this error when i start adding the fragments to the adapter :
adapter.addFragment(new FragmentName(), "TTILTE"); it says 'wrong first argument, u need to change the 1st argument to FragmentName() '
Have u an answer for me, it seems that a bunch of people are having this problem, check your video comment at "Fragment with Recyclerview Part 1"
viewPagerAdapter.AddFragment(new IPDpatientFragment(),"IPD Patient");
when i use this it is showing an error in(new IPDpatientFragment()).
Error is :-- Wrong 1st argument type. Found: 'com.example.mrjitesh.feedo.IPDpatientFragment', required: 'android.support.v4.app.Fragment.
can you please tell me solution of this.
which android studio version that you used?
Can we add collapsing toolbar with fragments
yesterday I was learning this tutorial from other channels. hahhaha coincidence.
hope you learn somthing from this video aswell :D
Bro in dependencies i have implementation as keyword and i am not able to add appBarLayout in that please help
omg bro 3days for do this shit
and this video have worked thx
Nice tutorial !! Keep spirit to make new ...
May i request for tutorial how to make simple note on android studio ?
if I have six tabs then I will take six fragment is it right way to create with tab time table?
sir I want to fast reply of my comment.
Nice Tutorial.
Please let me know how to sort titles of Tablayout, I have scrolling horizontal Tablayout with 8 recipe titles I want to sort alphabetically.
Hello there! I need to add ScrollView to the tabs, but I do not see the fragments when I add ScrollView
Hi, thank for your tutorial.
How can i set default tabLayout show is Store Tab?
Bro, just a ps.:, "compile" is not available in dependencies, neither Android Studio allows it, and is possible to create the fragment with xlm without writing of all the code.
But the step-by-step of the coding is nice and very instructible, thanks
thank you so much my friend
glad you liked the way i code
sir setupWithViewPager is not found when calling by tablayout
Thanks for the video , your videos really helped me alot
Spreading knowledge is a precious thing... Keep going 👍
Tq so much bro for this video about create fragments..
Thank you! This was really helpful. I did get an error though and I was wondering how to fix it. I made two tabs but only one of them is clickable, and when I try clicking the other one, nothing happens. Any idea where I might have made an error? The code compiles fine.
hello JungMin Lee
probably you made a mistake in the adapter check it out!
you can post your code for mainactivity and the viewpageradapter
i will be waiting
HELLO! HOW CAN EDIT THE "DESCRIPTION" TO PUT THE INFORMATION OF EACH ELEMENT, PLEASE.
Thank you, you are doing an excellent work with your videos!
Tabs doesn't switch when I tap on tabs but it works on when I swipe between the tabs plzz help me
Great tutorials! Please, i'm wondering if you can do a tutorial on bottom navigation with fragments. Thank you.
Yes sure
i add a spinner in my one fragment and include a layout in my main activity but the other screen wont work when i press it
i cant set android.support.design.widget.AppBarlayot on my android studio. plz,,help
J'ai la version d'android studio 1.3 est ce que c suffisant ?
ViewPagerAdapater Shows Cannot Resolve Symbol, any tips?
y como para pasar datos de un activity a este activity para los fragment?
Nice one
thank you for this video, it helping me so much
I luv ur work bro !! .. and it's really help-full ty so much for sharing !!
thanks firaz glad you liked my videos
Sir how is the click working? As we haven't added any method in onClick, does the TabLayout have the inbuilt feature of this?
yes it will be automatically set once you setup your tablayout with the viewpager
you can also customize the click event by overiding this method
tabLayout.addOnTabSelectedListener(new OnTabSelectedListener() {
@Override
public void onTabSelected(Tab tab) {
switch(tab.getPosition()) {
case 1 : additional work to do ....
}
}
Thank you sir
Sir can you please make a video on getting user's current location on map. And a video on routes between two points.
Works perfectly
can help me plz?
how as from navigation drawer go to this page?
i have "Unfortunately" mistake
tutorial is awesome thanks
Just a question, I want mine to be crated or placed in a fragment. Like the tab layout itself is on a fragment not activity.
its the same same thing, add the tablayout and the viewpager inside the frargment instead of actvity
Aws Rh actually sir I did but the findviewby id is red and has an error
inside oncreateview
mytab = v.findviewbyid(R.id.tabid)
You are awesome!!!! Thank you so much for this tutorial!!!!!!
i got a problem in
adapter.AddFragmnet(new fragmentsj(),"EVENTS");
adapter.AddFragmnet(new previousj(),"PREVIOUS");
adapter.AddFragmnet(new settingsj(),"SETTINGS");
if i was trying to solve that only one was not showing error and the other are errors
sry for the late show me your error you got in the logcat
yeah, i got it too
I know what your problem is. If you still have not fixed it, I can help u
i have the same problem it says change the 1st parameter of Addfragment form Fragment to my fragment java class what can i do please?
guys check your fragment class and make sure that it extends Fragment from :" android.support.v4.app.Fragment" and not from "android.app.Fragment"
also do the same thing for AddFragment Method Fragment android.support.v4.app.Fragment
Failed to deploy ViewPagerAdapter in the MainActivity
ViewPagerAdapter adapter = new ViewPagerAdapter(getSupportFragmentManager());
adapter.Addfragment(new fragment_tab_1(), "Fragmento 1");
adapter.Addfragment(new fragment_tab_2(), "Fragmento 1");
Failed addfragment
In your code how to enable click on one activity to another activity bro....?
Best tutorial for android studio please upload more videos new subscriber
i will, thank you
my fragments just arent there. the bar is there and all the code is correct, but i dont see anything when i switch between the tabs. wth
did you add a content to your fragments ?
also you can post your adapter and mainactivity codes here
Aws Rh I fixed it, I don't remember how but I ended up fixing it
do you remember how you fixed it?
Thanks man,great tutorial..keep up the good work
Sir I am writing compile 'com.android.support:design-26.1.0 in gradile file and than click on sync now but it is showing error saying Failed to resolve what to do to solve this problem?
'com.android.support:design:26.1.0 not 'com.android.support:design-26.1.0 , pls make sure your code is not wrong or you will get many error
great tutorial as always keep em coming
thank you Shingirai appreciate your support
Was very useful! Thank You :)
i want to be tabs in bottom what can i do?
wooow thanks man, I was really giving up
Thanks man, I like your videos!!
tablayout is not showing what should i do?
Fantastic man, I'm from of brazil, and yours videos are encridible, +1 inscrito
thank you so much for your video.that was very useful for me.
Around 20:30 you type ViewPagerAdapter adapter...... my ViewPagerAdapter is RED
Great working bro
Thanks a lot bro!! This is exactly what I was looking
Why are you adding design in gradle?
What change when u change elevation
Great video!
I get JUST this error in ViewPagerAdapter:
getItem(int) in "my app name" clashes with getItem(int) in "android.support.v4.app.FragmentPagerAdapter";
And if i write public android.support.v4.app.Fragment instead of just "public Fragment..." i get this ass error: (see image please) prnt.sc/lcyq7p
Anybody had this error and found a solution? Couldn't find a single solution to this, all codes for TabLayout have something that is obsolete, this was the one which i had some hopes it would work :D
@@WarNinGXK hey bro, but ur code in ViewPagerAdapter is
public Fragment getItem(int position) {
return fragmentList.get(position);
}
?? (int position) remember that! not (int i) or something else.
@@pipevski So, what's the problem?
Check in the video the minute 17:36 (ua-cam.com/video/7zaKUc2zfpI/v-deo.html)
Then check the line 24 and 25, it's exactly the same as i have it
@@WarNinGXK mmm, i send you my project? it works for me without problems, or send me the logs (sry for my bad english).
@@pipevski yes, please, sorry for the late response. Can you send it to: fabixdk@gmail.com ? If i can i will send you the logs too, but the emulator of android studio doesn't works on my PC.
Thank you!
I'm facing an error when I try to use the following code
adapter.AddFragment(new FragmentQuiz(),"Quiz");
It is saying that the parameter is not correct and have to change it from Fragment to FragmentQuiz.
Hello, you can fix the problem, go to FragmentQuiz.java and update "extends Fragment" with "extends android.support.v4.app.Fragment"
same problem i am facing too..
@@juanm38 this is not working for me..
Thanku man!
i was facing this issue as well and solved it by your help.
the last one isn't recognized :/ tablayout.setupWithViewPager(viewpager);
Thank You So Much Man..........................................
which laptop do you use ?
not a performant laptop but is still good for progrmming such as android programming and web development
my specs are
6 go of RAM
i3 3rd gen processor
intel hd 3000
I love the music
unable to resolve --> setupWithViewPager in main activity "tablayout.setupWithViewPager(viewPager);" can you share your sample and i want to know can i implement this tablayout on fragment
did you follow all the steps
okay i get that i implemented it on fragment thanks
finally!! I liked this video
when i run this application in emulator it shows unfortunately application has stopped
plzzz suggest what should i do?
check you logcat and see what error you got post it here