7 Apr 2020

Android Studio Tutorial Basic eCommerce App Tutorial

Welcome back in this part we will start working on our new project and that is going to be our online Easter F's so for doing this first we need to create a new project we can call it online Esther elves so online the in-store app hit this next button select the empty activity and finish and inside our girl folder make sure that you added all this required library so we need to add design library firebase database firebase poor firebase client and firebase UI database and card through and now sing this project maybe you already know this firebase or database is needed for our firebase recycle our adapter now we need to create a project inside our firebase.

So go to so log into your login with your email address and go to firebase database and create a new project so now we can see our griddle wheel is complete now we need to create a new project new fireworks project so harvest database you just need to log in with your email address now you can see this is our activity main so now open your fibrous go to your brother and you so now we need to create a new project inside our firebase database so at the project now we need to write our harvest project name.


we can call it online history up to and except all these terms and condition it next to you and click this continuing button now click this Android icon and in here you need to at our project back his name so go to your energy studio and copy your project package name and be stood here nod F snick name and now dividing signing certificate is optional so you do not need to add it and not click this register add pattern now we need to download this Google service JSON now copy this one and we need to add to this Google services on inside our project so move to Android to project and I stood here inside this app directory so now okay Google service JSON and now again moved to Android and click this next button.

now we need to copy this glass pot so copy this one and open this build or girdle project in here we need to paste this class part and at the Internet is play plugin and inside this builder trader module app at the end we need to paste this I plugin and now we need to sing our project you okay so is connected all this record field and click this next and now it will take few time too for checking so better.

 we can skip this stuff now if we click this database we will see lot of ocean but right now we will work with real-time database and just enable it maybe we can change our rules later you and go to these rules and change it to TRUE you and publish and to dismiss you now go to this activity main and we need to add our bottom actionbar and now we need to design our many activity layouts we need to first we need to add a floating action.

We need to add a bottom navigation bar remove this textview and to remove this constant layout and to need to add a relative layout and now we need to add Motum navigation view make sure they're inside your imputed griddle you added design library do not show so bottom navigation view so b7 we J to put on navigation view white mass parent and height select 56 TV that is the standard size of modem navigation view and at Laird parent Laird Ellen parent bottom true.

Now we can see our water navigation bar at the bottom now we need to define ID we can call it bottom bar welcome back once again in this part we will design our bottom navigation view in your previous tutorial we create our project we connected our firebase and we added our motive navigation view so first we need to create a new color call it colored name it's going to be bottom bar and choose a color what you want can choose this color and that background Dean so background-color bottom bar when it had background not background tinge and we define our idea was a different idea there is our bottom number okay now we need to add a frame layer select layout and select frame layout and add it here and we can drag and drop it here.

 I know it is full screen okay perfect okay now we can see our framelayout why heightened layout above and Elin Pelin bottom and Ellen / Nestor okay all done now we need to create a menu selected areas layer resource file and we can call it bottom menu and treesa starry sky should be menu and Toki and in here we need to add our item name so III team Android ID all title is going to be you can call it all and icon we need to create we need to add some icon so Java and select image asset and action bar and tap icon and click inside this clipart and for all we need to choose you this icon.

we can choose okay can choose we can choose disable and gents team to hollow dark and Jen Sydenham and call it all and to know next and finish we need to add two more icon Chansey to action bar and tap icon we can choose some random icon just put taste and changed him to holo light and name it get one and next and finish and two we need to one more you miss select action volunteer Vikon go to this clipart and we can choose you a gherkin just a second and change it to hollow dark and we can change this name to get to next and finish now we need to add icon con all

show a suction always and Android item id id we can call it get to one title is going to be cat one Icahn is going to be get one and show as auction and clearly another item I D I D is going to be get to and at title get to you and we need ed icon I can get to an show as action always you and we need to add this manner inside our boat of navigation view so fep menu it's going to beYOU can call it bottom menu okay but we can't see and the reason is that I think we need to clean our project so clean project you now we can see our background and now we can change our icon color so text color icon so item text color

Item my content is going to be color white welcome back once again in this part we'll connect your bottom navigation view with our Java file so go to this main activity private bottom navigation view bottom navigation view and bottom navigation bill is equal to find view by ID our dot bottom bottom bar that was our ID name and now this moto navigation view dot set on navigation item selected listener new on navigation item select a listener that is a required method for implement bottom navigation view you now we need to do Swiss casts so choice and get item ID case r dot r dot all you we need to return it true and we need to change this background color

who in easily and you of this item so we need to choose a color so create a new color attribute so color is going to be all all the bottom and choose a color then we can choose this color so color get one and for this cat one we can choose this color this color and for color get to you and we can copy this one so bottom navigation view not set item background resource our dot color dot you all bottom you and case our daughter DDOT get one Motum navigation view dot set item background resource r dot color dirt get one and we need to return true and case r dot ID dot get to so bottom navigation view got the set item background resource r dot color dot get to to return true and do we need to add and default and default will be false so cut this return false and paste it here now all done for implement floating effort implement bottom navigation view now we can run our f now we can see our bottom navigation view 

so if we click this icon again we can see our background color it changes so all these down in our next part we will implement our fragment inside our bottom navigation view so there's it for this part welcome back once again in this part we will connect our fragment with our bottom navigation view so for doing this first we need to create see fragment right-click and but this fragment Blanc fragment and instead of block fragment we can call it all fragments and finish and create one more fragment and uncheck this line of protocol and get one fragment finish you and the fragment and two we can call it get to fragment and finish you so private now we need to add all this fragment so private all fragment going to be all fragment private get one fragment is going to be cat one fragment private cat to fragment is going to be cut to fragment and all frogmen is equal to a new wall fragment cat one fragment is equal to new cat one fragment and get to flagman is equal to a new kite to fragment you now

 we need to create a new method so public void can call it a set fragment and inside this parameter we need to pass fragment make sure that we added fragment from before and it's going to be fragment now we need to add fragment transaction so select transit transition is going to be fragment transaction is equal to get support fragment manager transition fragment transaction dot reflects r dot r dot and in here we need to write our frame i D maybe we did know that any ID inside our frame Lord so go to this one and in here we need to add a ID for our frame not and we can call it ID we can call it mainframe i d-- and is going to be mainframe and the second parameter is going to be over this fragment and now we need to commit this fragment transaction so fragment transaction dot commit now we need to call this method and color all fragments in traditional event by default 

we want to like to open our all fragment and when user will click this on a button and we need to show our all fragment no inside our get one fragment called this method set fragment and call this get one fragment dedicated object of our fragment and for our get to fragment we also need to add set fragment and this fragment is going to be get to fragment you now we can change our text just for check our fragment is working or not we can adjust we can show you just message so you can call it all fragment and fork at one and we can call it fragment cat one so fragment to and now hit this Run button now we can see by default or all fragment is open and if we click this all button and we can see our old fragment and we can see how a check may be our only chance now if you click this get one and we can see fragment get one and if we click at two and we can see our get two fragments

 so that means we successfully we successfully added all this functionality and we can we can move from one fragment to another fragment when we will click this bottom navigation bar icon so I think there's enough for this part in our next part we will start working with our fragment make sure that you are following step by step so that's it for this part welcome back once again in this part we will work with our recyclerview so for doing this first we need to open our all fragment out so open this fragment only out and remove this textview and instead of femme layout we need to add linear layout and now we need to add orientation particle at a relatively at the eddy recyclerview white mass parent and hide mass parent they we need to change it later a state ID so ID we can call it recycle er all and now go to this old fragment remove this construct of it onto any constructor and remove this comment and create an object of EU + view is going to be my view is equal to inflator now we can return this view so return my view now we need to create our fire our recyclerview so brevet recycle of you is going to be all recycle er and all recycle are is equal to my few dot find few by ID I DDOT recycle at all linear load manager lead manager is equal to new linear layer manager get activity and second parameter is horizontal cause this time and second parameter is last feminist false cause 

this time we want to retrieve our recycle fu horizontally so for this reason we need to add this linear load manager at horizontal make sure that you've added this line of code you and now this loud manager dot set reversely our true and alert manager dog stuck from intro and to all recycle a dot set has fixed size true and all recycle a dot set layout manager and this layout manager is going to be layout manager you instead of height masked parent we need to choose height 300 DP and before that we need to add a text view white mast parent and high-tech content and at Dick's and we can call it get one and to layout margin den DP and tender paddington DP and text appearance the parents loves you and 22 one more recyclerview and before that we also need to add one more textview so textview white mask parent and hi drop content and at allowed margin 50b and we need to add padding so padding 10 DP and Android text appearance and text appearance is going to be large and we need to add text and text we can call it cat too and now we need to add our recyclerview so recyclerview white man's parent and height is going to be 300 DP Android ID ID is going to be very secular basically k2 you and I think we need to add a scroll view first unit to the linear layer to linear layered white mass pair and Hydra content and that orientation particle inside this linear load for that we need to address call view and inside 

our is call view we need to add in this linear lab so is called view white mass parent and height wrap content and minimize this linear loud and cut it and paste it inside this scroll view and inside our linear layout we need to we can cut all this field and paste it now we can install our recycle our view and our text view so instead of height I think okay all good make sure that we added all these do cut field though I think all design is done maybe in maybe later we need to modify some height or white for a very secular view and we will solve it later and now for now I think is good now open this all fragment now we need to connect this to recyclerview so we already connected to one recyclerview that was well that was our first and we can and we count it category secular and we need to add one more secular item so this one is for our cat too so get to recycler Oh private recyclerview and we can call it recycle of you get to you to recycle I get to is equal to my few dot find view by ID our dot ID dot recycle our cat too linear load manager layout manager load manager cat to is equal to new linear load manager get activity we are working with we are working in fragments so there so we need to add get activity instant of context and linear layer manager dot horizontal and last forever our last parameter is FALSE you and now this loud manager Larry another cat to dot set a stack from in true 

and now laughs manager cat to dot set a stock form into true recycle of you get to dot set has fixed size true and recyclerview get to Dodd set layout manager is going to be - so we set our to recycle and view so we successfully set our two recyclerview and in our next part we need to create two new class and we will need to extend our recycle a view holder class I think that is enough for this part in our next part we'll work for our rest of stuff that you are following step by step so that's it for this part thank you welcome back once again in this part we will design our recycler item data so for doing this first we need to create a new layer we can call it layout we can call it Jim data so you can call it item data and okay and remove this constant loud at God whew and change this layout height misspell into rap content and we need to select layout wait the white we can choose to therapy of to a TDP okay we can modify it later and add a layout margin 5dp you not five to play at NTP you and at car television ten DP and or elevation 10 dB you and now we need to add a linear load white mass parent and height is going to be rap content and now we need to add the orientation orientation vertical so image view on the military miss view why transparent and right we can choose to 40db you so image view white mass parent and height 240 DP and inside our card few we added white going to DP so we can use the white man's parent and Android ID and ID is going to be can call it image view you textview why transparent and hide wrap content and Ted fading reading 7dp and you need to add a text we can call the title and add text appearance text appearance medium and we need to add maxximum lines one and we need to choose a text color so text colour should be black and tune it to add ID so ID we can call it title okay you so instead of image height 240

 we can chooses to 20 DP okay or 200 DP I think we need to increase our size okay fast edit text view for our description so Dex pure white mass parent and height should be rap content you and to need to add bedding and we can choose 7dp and Android text can call the description and for description MECs lens - and text appearance is going to be dextra parents is small and tender text color this color is going to be color-block and we need to choose the ID so we can only need to add ID so I D is going to be description I think for this time this layout is perfect if we need to modify it then we can modify it later make sure that you added all this Dukat field of course we will retrieve all this data from our firebase database so I think there's it for this part we will continue it from our next part welcome back one second in this part we will create our model class in our previous part we added all these item data that we will retry in our application so for doing this fast we need to add so fast create a new package we can call it model okay and inside this model package we need to add a new class and this class is going to be data you so private string title first a tea miss private string title private e-string description bifur tasting i D now first we need to add a blank constructor so public data now we can generate our constructor and getter and setter so right click you and generate constructor select all okay and generate getter and setter select all and okay so we successfully created our model plus our constructor our getter and setter make sure that you added all these variable and getter and setter and don't forget to add a blank instructor with us this blank instructor it will not work so that's it welcome back once again in this part we will create a very secular class but we need to create two custom class so go to this old fragment and who need to create a new class you can call it public first 

we need to add our own Eastern method - no we can so public static plus we can call it cat one you can call it cat one viewholder extends recycle are few dot pew holder and now we need to now we need to create a constructor and now create a object of our view class subview is going to be my view and this my view is equal to itemview not when you do it method so public Boyd we can call it said first it said title and we need to pass steam parameter so is drink title so textview you can choose em title is equal to my few dot find view by ID don't what was the ID name so our ID name was title better so our name is title and died now am title dot set text is going to be our this title and public Boyd set description you so easting this one is going to description and textview I'm description is equal to my view dot find view by ID our dot I do you so our idea means description so our dot I read your description and em description dot said text is going to be dis description now we can clean this project so clean project okay now I think all done now go to this builder trade-off and we need to add our Picasso library so go to Google and search for because

 M is not a library and you will get this this library and add it inside our inside your blood girdle and seeing this project so now create a new method so public void set image without this library without this Gradle because of Godot library we will not be able to retell our image from our firebase database so make sure that you added this precursor in Gradle library and and added inside your build.gradle file now we need to add our image view so image view MMS is equal to my view dot find view by ID r dot ID dot dadada da team is view and now this because Oh God get dot Lord do you want to

 Lord we want to load this image he means dot network policy network policy offline not into where you want to Lord we want to have set it inside our image boom that is our image view so into MMS and to new Colbeck so mms new Colbeck and and it will give us to method one is for unsuccess and one is for on arrow now we need to set it in cities on your so pika so dot get not image dot into and Amos so I think all functionally done for a trip our emails from our firebase database welcome back once again in this patch we will set our get 1p holdout inside our fibrous recycle adapter so open so go to this honest method and now we need to implement our firebase recycle adapter so firebase recycle our adapter and first parameter is our model class that is data and the second parameter is yet one pew holder a doctor we call repre one new fire waste recycle adapter you now 

we need to add a model Plus on data dot class winter alert so r dot dot item data you and we need to at our cat one beholder plus and last one is our database but we did not create any database yet so we need to create our firebase database so private database reference we can call it em card one I'm caught one database you and we need to create another database so private database reference I can call it an cut to database you MCAD database firebase database dot get instance dot and get your friends dot child and we can call it we can you can call it cat one get one database you instead of card I think we need to change it to cat okay and now we need to get to database so get to database is equal to firebase database dot getinstance dot get reference dot child and we can call it get to database get to database you so this one is for our MCAT one database so behold a dot my few dot not my view so behold a daughter said title model dot get title pyew hold on said description model don't get description mahalo dot sette miss model dot get image you and now we need to set this adapter with our recyclerview so first one 

is overall recycler dot set adapter is going to be adapter one so I think all functionality done so that's it for this part we will continue it from our next part once again in this part we will create custom recycle a class for our cat to so we need to create one more class so public static plus we can call it cat too we can call it cat dope you holder and this one will extend so X x recyclerview dot viewholder now we need to create a constructor so create a constructor subview is going to be em view and this mu is equal to item view you so public void set title sting is going to be title so textview em title is equal to ambu dot find view by ID r dot ID dot our da da da da title am title dot set text is going to be title so public public poet said description easting description so take spew M discussion mu dot signed view by ID r dot ID dot description now em description dot set text is going to be dis description you now we need to create one more method for our so we can edit mca title on MSN description method we can chance it okay no problem you can add any name whatever you want now create another method so public Boyet a

m set image is string image so image view mm is enemies view ambu dot find view by ID imageview now we need to implement our pika so you so because our dot get dot load Rison we want a lot we want to load our image so image dot Network policy NATO policy offline dot into how do you want to load went a lot inside our MMS so a meme is pew and new Colbeck now this method will give us two method to 1 1 is on success and one is on leader and inside this on leader and inside this onei door we can add it precursor dot get not Lord image dot into I'm amiss whew you welcome back once again in this part we will retrace our get to data to go to this on asteroid method and we also and we need to add implement one more fire very secular adapter for our cat too so fibrous recycle adapter last one is data and Sega nominees our class name get to viewholder and you can call it adapter 

too new fire waste recycle adapter you now data dot plus-- there is a model class and you need to add our layout r dot layout dot item later mcat to database it is our database name and before that we need to add our class name so get to behold a dot plus you so behold a dot am said title model dog a title you hold a dot MC description model dot cat description and if you hold a dot I'm sorry miss model dog Adiemus okay now we need to set our and secular view so recycle our view was the secular if you get to dot set adapter and this one is going to be adapter to so I think all these required functionality done so we successfully implemented two fibers recycle our adapter for our to recycle a few and we added all this required field that we need to have for retrieving our data from our firebase database so inside our own Eastern method we added to firebase recycle adapter and do we get it to class

 so there's it welcome back once again in this part we will post our data from our firebase database so go to this farva's database and create a database make sure that you added same name so cat1 database and add a post key and add our title and we can call it first post and we need to add in description make sure that we added exact same name so you can call it we are now working on our new project that is called online Esther F this is our first post and post now we can see our cat one data we can see our title and we can see our description but we can't see our image so we need to upload fast uploaded image so go to the distress and now we need to upload so click this output file so I let some dummy mess there is a screenshot of my coat so so for outputting image you need to go toy stories and click this upload file button and then to let all these images so now if we click any of this image and we will see all description and you can see our file location and our download URL now click this one then you can see copy to clipboard and now go to this database and we need to add one more field you can call it image

we need to paste it here and at so we added our image URL now we can see our image so we successfully inserted our image our title and our description I think all the working good let's post one more so at first when you tell a post key so make sure that you are doing a sequence so this one is ps1 so we need to write here ps2 if we don't maintain the sequence then and then we can see this we can see our data in Reverse smooth so first when you trade our title and call it title second post and we can see one more one more item and to let's add description so description just at some dummy description we can call it we are working on 

we are working on this project and [Music] it's our second and it's our second post and ad and we need to add image so go to these histories you and choose this file location and copy this download URL you and image and paste it and now add now we can see our second image so all are working perfectly this is our cat one data and we can is polish horizontally let's add one more pose ps3 at attributing a make sure that we added say misspelling otherwise it will not work so title is going to be thought post at description so at description is going to be this is our third post add we need to add image so go to this storage folder you and we need to do this file location' so copy this one to clipboard and go to this database you and we need that image attribute so image and value and paste it and add now we can see three post but still we have some layout issue so we need to solve this you okay now we need to add one more database for our cat too so go to your court and make sure that we added same database name so forget to our database name was get to database you and we need to add a key and call it ps1 

and to unattractive and we can call it first post and description you you can call it hello this is our this is our first post you and forget - we can see our data is it right but we can't see our image and still we have some layout design issue so first at your image so go to this storage folder and select the image file location and download it you select database you and looking at image and Edie now you can see our image so we need to solve our layout design so go to this item data so what is the main problem I think main problem is instead of white height and fellini allowed you so in here our I think inside our recyclerview we have some problem we need to solve this design issue you okay so we have problem for our height and we have problem for our okay let's add one more post for our cat - so ps2 pH title so title is going to you can call it second post and add one

 more title it's description and we can call this is our I think all this is our second post and we can see for cat one we have three post and for cat - we can see our first post and second post I don't know how it's not reversed mode we need to solve this problem okay fast edger you miss you so copy this download URL you and when you dirty us field so a mess and AD and now we can see but it should become in Reverse mode maybe we did know that Riversleigh are TRUE so thought for second post and first post so if we see if we have a look okay so we did know that it stuck okay we did a mistake we had a stuck sadistic moment true to time so inhale we need to add set reverse layout true now hit dis turn button once again you now we can see our data is in reverse mode so second post then first post okay so we successfully retrieve our data from our firebase database and we set it inside our recyclerview but still we have some design issue and we need to solve it so make sure that we added all this recycler option or maybe we have probably inside our item data we added yup Khan instead of web content select 300db and hit this one button once again you No we can see extra-large size so but can we do or solve this issue so instead of height 300 DP we can choose it we can choose 8 to 10 DP or to 30 dB you you still have some problem we need to add some larger size for our height so instead of 230 DP it's better to chose 270 DP and hit these on button once again you okay now I think all done perfectly so get to second post and third post you on instead of text appearance

 we need to change this to text appearance medium and for this textview gents text appearance medium [Music] you and you move this layout merging 15 DP and now hit the Run button you now I think all done perfectly now we have a nice design so we successfully retire our image our title our description and we can do it horizontally we can set it data to horizontally so all done perfectly so I think that's it for this part in our next part we will set our data for our details activity welcome back once again in this part we will set our data for our details activity so when we will click this any of this item we will move to our details activity so first we need to create a new activity so activity gallery empty activity and we can call it details activity or I can call it get on details activity and finish you now create one more activity for our get to so you can call it get to details activity and finish you so go to this all fragment you so five waste recycle our adapter inside our fibrous recycle our adapter so for our cat 1 recycle adapter so 5 is 4 so 4 get one new holder when you get a set on click listener so viewholder dot my view you to make sure that we added the right object of our view class so view holder taught my view not set on click listener new on click listener you now we need to pass the intent so intent intent is a call to new intent and get activity and we will move to cat one get one details so get on details activity dot class now in 10.2 extra we need to add a key is title and model dot and get title and in ten dot boo Dexter description model dot and get description so in 10.2 Dexter and we need to pass our image so image aunt model dot get image and when it tasted our activity is so a stirred activity intent so that's it for this part welcome back once again in this part we will set our data for our cat to so go to this get to beholder fire very sick or adapter and in here we need to add one more set on web listener so fill hole dot M view and this mu is for get to view holder view object so mu dot set onclicklistener new onclicklistener so now intent intent is equal to new intent get activity you and we will move to our cat to details activity so get to details activity dot plus-- now in 10.2 extra title model dot and get title in 10.2 extra in description model Laden cat description you and in ten dot put extra ms model dot to get image and now we need to start our activity so Esther activity intent so that's it for this part thank you welcome back once again in this part we will design our teachers activity level so when either will click any of any of our item then they will redirect to literacy activity and inside our detailed activity we will show them all these details of title description and images so open this cat one deters activity and to remove this constant note and we need to add linear layout at linearlayout at orientation particle and you need to add S corp you white mass parent and height up content uh no need to add a linear load white mass parent and height Arab content and you need to add orientation particle you now we need to add image view white mask parent and hide you 40 massive you can choose hide actually she DP you Liat margin 5dp anti-d we can call it ID i de mis details DT and now we need a text view so text view white mask parent and height adapt content layout margin 5dp and add text appearance text appearance medium and at text and we can call it postitive and we need to add the ID before that first chance is text color so text color and choose all button ah we can choose this bottom bar color okay and now we need to define the idea for our title so you can call it title DT that'll details and - we need to one more textview the textview white mask parent and hide wrap content and to layout margin 5dp and ID idea is going to be description it is going to be description details and text color and Dex color-block and text appearance text appearance is small and you need to add few text you can choose it description okay so we added our image our title and our description now I think our deters design is done for our cat one and forget to details we also need to have same design so remove this constantly out at linear layout and at orientation vertical now we can copy this code and paste it so copy the scroll view flower from our cat one and paste it to get to details cuz we need because we need to have some input field we need to add Sam's email sent a text view and description so we need to SEM layout so you can simply copy and paste it here so that's it for this part in our next part we will set our data so thank you welcome back once again now in this part we will set our data to our details activity so go to this cat activity private image view you can call it MSP private textview title and private textview description you imageview is equal to find view by ID our daughter DDOT in this view and title is equal to find pew by ID title details so our imageview idea was maybe image DT make sure that we added same name so image TT and your description is equal to find view by ID r dot r dot description details now intent intent is equal to get intent is Jing em title in ten dot and greatest in extra and make sure that we added exact same name that that was our key so I get one view holder our key is title so our key is tighter and easting em description intend on getting extra aqua DS description and paste it here we need to add same key and his sting you can call it MMS is equal to int n dot get easting extra and this one is going to be our image now we need to set all our title and description an image to our text view so title Lord set text amp title description dot set text M discussion and now we choose our pika so so pick Assad get dirt load mm a start into dot dot network policy and tenet of policy offline dot into why do you want to load we want to load inside world image view so image view and next parameter is going to be new callback and inside our Oliver so because Haddad get nod Lord can call em you may start into II miss pew you now hit this Run button once again okay so now if we click any of this item for our for our cat one so click this on so this one is our cat one and these two is form our get to database now if we click any of this item from our cat one database will we will redirect to our details activity so now we can see our image our title and our description so now we are in our get one details activity and if we click on second post then we will see our second post data so you can see our image our title and our description so for different see how a difference item so if we click our first post so if you click second post then you can see our second post data so all done perfectly oh I think that's it for this part welcome back once again in this part we will set our kit to data to our get to details activity so police care to deters activity and add all this field so private he may seem his view and Fri where text view is going to be title and private text who is going to be description so image view is equal to find view by ID our daughter debt image DT title is going to be find view by ID r dot ID dot title details and description is equal to a fine view by ID r dot r dot description details so he's doing em title so first we need to pass in terms of intent intent is equal to get in 10 so easting is equal to intend dot get e-string extra Title II staying em description is equal to in ten dot distinct extra and we need to copy our description key and easting mm s intended getting extra you miss and now we need to set all this field so title dot septics is going to be M title and description dot set text is going to be M description and need to add Picasso Picasso don't get dot lot am amazed dot network policy Network policy dot offline dot into image view dot you call back now in now inside this onei door so picker so dot get lot MMA's dot into image field you now here's John Burton you so now if we click off any of this item from our head to database we will redirect to our details activity so now we can see our image our title and our description now if we click our first post then you'll see okay so all functionality done so we successfully set our data to our details activity for is item you now I think we need to add bad patterns so go to this manifest file so when we'll click we need to add a back button at the at the top of toolbar so how can I do it so if we want to do it we need to change it to our manifest files open your manifest file and Android manifest here you will see our Kat Von D test activity and in here you need to add one more attribute and activities for parent activity the parent activity name not mainactivity so our main activity is our parent activity so when we are in only just activity then we'll move to our per negativity that is our main activity not for our cat to details activity so parent activity name dot main activity now go to this cat to deters activity and inside the Java file you need to add to line up court for enable these so for enable this back button you gets a production bar dot set display Hamas of enable true and get separation bar dot set display home SF enable true maybe we added so copy this on we need to air to one time not to time if you had this line of code will be able to see our back pattern now run this else we need to add it one time don't add it to time you so very sorry molecular hurt there now we can see our all of this data now if we click any of this item now we are in details activity and we can see our back button and if we click this back button we're in our main activity so we successfully enable this back button ok so it's now working perfectly okay so I think all done perfectly so we can see our details data and we can work with our back button and our floating water and our navigation and our bottle navigation bar is working so that's it for this part thank you welcome back once again in this part we will design our layout for our cat 1 and cat to fragment so create a new layout resource file and we can call it custom item data and ok remove this constantly out and first we need to record view and do we need to change our height math parent to wrap content and we need to add a layout margin 5 dB and a pee-pee we need to add our car television so card elevation 10 DB and Android elevation 10 DB you in here we need to have one image one is P one title one not so first we need to add a linear load you so fast when it had linear layout linear layout white mass parent and hide rap content and now we need to add orientation 

particle you and we need to add one more loud white mass parent and high drop content and at orientation horizontal you and now we need to add relativelayout oh why - 0tp and hide rap content and to layout do it who can select do and now inside this relativelayout we need to add a image pill so you miss pure-white should be mass parent and hide 50 DP or a teen 200 DP we will modify it later can choose 170 DP I think better is to choose 160 DP you and now we need one more relative layout for our and not ideal and not Oh title and description not not so copied is relatively out so create one more relativelayout white 0dp and hide

 rap content until a outward see or you can just for I think tea is better now we need to add our text view text view white mass parent and hide wrap content Android layout margin lay out margin to DP Android text we can call it post title and to take staples dextra Paris medium Android text color we can choose this color Mortimer color this one is our image - and this one is our title you and turn it to a tidy you so we can call it post title and tune it one more take spew white mass parent and hide rap content I own it - at layout below and our previous ID is by post title ok so layered below post title now at layout margin - DP Android text you can call it post description and we need to choose text appearance so text appearance is small you and you need to choose text color so text color - Android text color-block and we need to define ID we can call it post details so I think all done perfectly so we are the one who need to add the ID inside our image view so ID we can call it post image all right your design is complete if we need to do any modification we will do it later make sure that you are following this step-by-step process okay so we have one image one title and one description so that's it for this part welcome back on in in this part we will retire our data and settle and we'll set our data inside our cat one data fragment so for doing this first we need to open our cat one fragment so open the scattered fragments and first remove this constant loud this constructor we don't need any constructor now we need to create the object of our view class so view is going to be my view and now we need to return our my

 view so return my view you and now we need to implement our recycle of you so first we need to add recycle level inside our fragment so open your Ratman k2 cat one and remove this textview remove this family out and at linear loud and - we need to add orientation particle and now we need to add a recyclerview white mass parent and height adapt content anti-d we can call it recycler get to one and I open this cation fragment profit recycle of you you say I love you now this recycle our view is a call to find view by dr dot one you make sure that we added the same name okay now we need to add linear load manager linear load manager layout manager is a call to new linear load manager activity and now this layout manager now this layout manager dot set stock from intro anti layout manager dot sat reverse layout set reverse lair true and now layout manager and now we to add every secular view so recycler view dot set has fixed size true recyclerview dot set layout manager is going to be this layout manager now we need to add our fire voice database reference so private database reference we can call em cat one get one database mcat one database is a call to firebase database dot to get instance dot get reference dot child make sure that we added exact same database name so what was the mall database name our database name was cat one database to copy this Couture database and bass do too and no need to mcat one database dot give sync true and cation database dot keep synced true you now

 we need to create our first we'll implement our own Esther method okay I can put on a step method now create a new custom plus public aesthetic class I can choose you can call cat one beholder and it should be extent view dot pew hold on you subview is going to be M view now this mu is equal to item view you now we need to add our method so public void our method said title easting title now add text view so textview we can college em title equal to MU dot fine view by ID fine view by ID r dot ID dot both title and em title dot said text is going to be title public Freud said description is during discussion textview em description is equal to mu dot five view by ID post details that was our ID name now M description dot set text is going to be our description you okay now we need to add to one more method for our in this you public Boyet I can call it set amis you miss and in this view is going to be a me miss is equal to mu dot five view by ID and we can call it post image now we need to implement our picasso library so picasso dot get not lot what we want to lot we want to learn our emails so image you dot network policy and network police offline dot into her you want to load we want to load inside our image view I'm amazed and second parameter is going to be our new callback so new callback method now Picasso get that load image dot into you um image now we need to implement our fibrous recycle adapter so go to this honest read method and implement firebase recycle adapter data and 

we need to add our cat one beholder you and adapter is equal to new fibrous recycle adapter and inside this parameter you need to pass our model class name our layer so fast passed model class so data dot plus second parameter is going to give a layout our dot layout or custom item data and third one is our view holder class so get one view holder dot so get on Bueller you we try to work at one pure class dot class and last one is our database name you okay and our database name is mk2 one database so am get one database now inside our bubbler we will need to set all this method subu holder dot set that related the other method and model dot get title behold a dot set description model dot get description and if you hold that dot set image model dot get EMS 

okay now I think all done and now we need to set our adapter inside our recycle our view so recycler view dot said adapter is going to be adapter nor on deserves you so share is the replication ting now if we click this this is our home Lord if you click on cat or now we can see our image our title and our discussion but I think we need to solve some layout design issue okay so we need to sum we need to solve some design issue like image title and description so go to this open up your nicht open our Item better so instant of white mass parent okay OOP a linear load so height 160 dB you so inside our card view we added height up content and vitamist parent and I think instead of hydric content we can select a specific height we can we can choose 200 DP let's see how it look like 170 DP you now run DCF second you not yet or no we can't see any changes still you need to solve this issue you and [Music] but you miss chance this way 2 2 3 2 2 v2 think we need to change our image height instead of 160 DP 

so we are the relatively high drop Khan and no just MSP height wrap content and run this f second and if we were to ever get one now see now you can see some changes but I think the problem is that our image size image height is lower so maybe that is the reason or we can change our card few hi 206 7 ATP 220 DP and for our discussion at maximum lines to and for our title texture at maximum lines one and hit design battle you okay now we can see some changes I think that is enough good but we need to increase our we need to increase our image size miss Hyde the instant of web content for a relative imaginative layout we can choose it 150 DP so we added our card beforehand 20 DP and change it 240 DP and change it 230 TP nor on deserve second now go to this cat one so I think the reason is that our image size is lower your size is smaller this way we can increase our image height thing is perfect enough or we can change it you if you choose one more you need to choose two for linear load Heidi's wrap content chances linear load height to mass parent and for this linen loud height now hit discern button and for this image size choose height mass parent button

 


Previous Post
Next Post

0 comments: