Hello this is Martez or Corddry.
And in this story are you going to work on the expanded view.
First of all as you can see I am inside these uncreate Smurfette and here before the ending really of
this Meffert I am inside is uncreate me and I am going to access the expanded view.
So Vinita create a valuable first.
It's going to be final.
So it cannot be changed later.
The value of this variable cannot be changed.
And the hype is going to be View and The name is going to be expanded view expanded view assignment
operator.
Lets refer to our widget floating widget dot find view by id r that Id got expanded view semicolon.
Now we can access.
Let me show you the emulator there while we have this live image.
So I am going to create an unclick listener for this lion image.
First we need to access this image.
So let's say that we are going to have an image view image view.
Its name is going to be like an image assignment operator.
So let's cast it to an image view.
Find view ID.
Excuse me we need to refer to our visit first floating which it does find view.
Id artist Id that lion image semicolon.
Now we can see like an image that sits on a click listener and we need to pass the context.
So the context is the service fluting View service
with Capitol floatable So we start this.
Now we can go inside is unclear Smurfette after this break statement we can say case our ID that lion
image call let's create a Toastmasters let's say TOSed make text fluting your service Carmo the text
is going to be like when is tapped
Khama the screen to be sure it's Daut show.
So let's create a new line and then break.
So let's go back to our uncreate and then let me show you the emulator.
So we're going to create a listener or click listener for this previous spot.
So here I am going to say that we have again an image for you so its name is going to be Previous button
assignment operator.
Its name is going to be is really the classic 20 minute view object floating widget that find fine view
ID or the ID that previous Pythian previous semicolon.
So if you know how to proceed from now on you can actually just skip the video but I'm going to code
this and create it here manually or you can just copy and paste.
A good idea.
So let's say that we have a previous button that sits on click listener and ave to pass the context.
So floating your services Capitol that this an ongoing site is an effort and we can't say case
art that Id dot.
So when this refer to the idea that the idea is pity previous call and so let's copy this message here.
And pasted here.
So the value is going to be here instead of lawyer type in here previous button is tath and then bridge.
OK.
So let's go into this.
Uncreate method here again.
So let me show the emulator.
We have this Leppert image.
So now let me just copy these two lines of code here.
Let's paste it here so that we have the Leppert Emmets
here.
You're going to access the first image and we need to say Leffert image that unclick the center and
we pass the context so here we are going into a can copy this case and paste it here.
So now we are going to see our leopard image.
So here it is a leopard image is clicked.
So let's use a capital L.
Let's go back to the uncreate and then we have the next button.
So here we are going to copy and paste these two lines of code here.
So the name is going to be next.
Button.
So here we are going to refer to the next path in between.
Next we're going to see the next button.
Then click the center and the context.
So let's copy and paste this case here.
And the value is going to be next.
But in between next.
So here we are going to see that the next button is tapped next button is tapped right.
So let's go back to the uncreate method here
let me show you the emulator.
So now we have these two buttons the close button and the open image.
So lets access the close button.
Let's say that we have an image view and its name is going to be expanded.
Close but it expanded close button assignment operator let's cast it to an image view finder view floating
widget floating widget that fine view Id artist Id that expanded close in close with an expanded semicolon.
So let me create a new line so that you can see whats going on here.
And then we need to create that unclick listener.
Expanded the close button expand think the set on click listener and the context is going to be floating.
You said that this on here inside these on click it again you can actually create a case.
So let me copy and paste this one here.
So kickstarted I did that expanded close to close but then expanded and here at the value the name is
going to be expanded.
Close but then is tapped.
So let me create a new line
now.
Finally are going to actually create a listener and click listener for this of an image.
So here we can say make get inside this and create an image view or pin button.
Assignment operator lets just to add an image of you object floating rigid.
Thats fine.
Id art that Id dot or pin button semicolon that say Open button that certain click listener.
And really to pass the context which is going to be floating your service that this and ready to go
inside this unclick effort here below this case you're going to say case bar that's ID dot open button.
Colin posts that make text that make text the context fluting Youth Service that this come up and the
text is going to be open image is tapped.
And finally you need to specify the duration of this message thats short show.
So let me create a new line here.
And finally we need to put the brakes statement here break.
So that sort of we created all of these our listeners for all of the components of our expanded state
here.
So now let me show you the emulator here.
And then the user Papps for clicks and this close button here the collapsed view is going to be shown
to the user.
And when the user clicks and this open image often button here the main application is going to be open
to the main activity.
Right.
So let's go back to the Android studio here.
Let's go and it is unclear if it when the user clicks or taps undisclosed button expand expanded.
I want the collapsed view to be visible.
And I want the expanded view to be gone.
So inside this Arncliffe effort and inside this case are that ID that close button expanded after this
TOSed message here.
I need to refer to the collapsed view but I cannot do that here.
Here I am inside another method.
Unclear if it but the collapsed view.
Let me scroll to the top inside this on creating of it the collapsed view is actually created inside
is uncreate me and I cannot access this variable in from our uncollectable for it.
So there is a problem here how to solve this problem.
Now we can actually pause the video and solve this problem.
But on your own and if you cannot do that you can actually play the video.
But I'm going to solve the problem now here.
You can actually say that we have this valuable here Club collapse view inside this and create it.
But let's keep it this value here.
Final view collapsed.
Let's scroll up and let's declare this valuable insight is class float floating view service and let's
place this value here.
Cynical but there is a problem here.
The Instance variables or the valuables that are declared inside the class cannot be fined.
OK.
And this means that this final here should be deleted.
So now that we actually declare this variable here inside this class we can scroll down here.
So we have this final view.
It's actually the final view collapsed view.
You can see that here right now it's this final and view because now this collapsed view refers to our
instance variables to this collapsed view variable that is actually declared inside this floating View
service which can do the same thing for the expanded view we can see view and the name is going to be
expanded view semicolon right now.
Let's scroll down here.
Let's find the expanded view of our table.
So here it is.
Final view expanded you right now let's delete the view and the final.
So that is expanded view here actually refers to an instance variable.
Expand that view that is declared inside this floating Bucephalus class.
Let's scroll down here.
Now we can go inside this unclever fed and for this case are that ID that close but an expanded third
is Toastmasters.
I can't say collapsed view
that set visibility view but visible OK.
And we need to actually close the expanded view so we can see a expanded view.
That said visibility view that's gone now we can see that when they close button is clicked the class
the collapsed view is going to be shown to the user and the expanded view is going to be gone.
And let's go for inside this case or that I did not open water.
Now we need to create an Internet first.
Actually say intent and the name is going to be open up intent assignment operator new intent context
which is going to be a floating view service that this and we need to actually refer as a signal we
need to refer to the class that we want to move to.
We want to transition to another class right.
So this is going to be main activity that class and finally leaving it with a semicolon at the end of
our statement.
Let me create a new line so that you can see what's going on here.
So now we have this intent now Vinnie to actually add a flag to this intent.
Let's say that we have the open app intent but at Flack's and the flags that we want to use here is
going to be new.
Activity and flag activity new task cynical.
So we used this flag here because of duplicity problems up here.
If you don't specify it is like for this intent for this app intent here then there are going to be
two instances of the main activity class and we may actually wind up with memory problems and that's
not good that's not a good programming practice.
So here instead of sort of creating two activities we decided to use this solution.
And by using this flag only one instance of the main activity is going to be created when the service
is actually stopped.
When we want to actually start the service and move to the main activity and here they start activity
and we just need to pass the open intent.
Finally we need to say stop self in order to stop the.
OK so that's it that's enough for this tutorial.
And in the next story all we're going to specify how to track the widget over the other views how to
try to get it over our screen by using the Tochtli center.
So thank you very much for watching.
If you have any questions about these concepts that you've learned so far please post the discussion
in the course and then I'll do my best to answer all of your questions.
Thank you very much for watching.
And I look forward to seeing you in the next story.