Android RecyclerView Step-by-Step Tutorial (Part 7) - Event Listener

Android RecyclerView Step-by-Step Tutorial (Part 7) - Event Listener - Hello friends Android tutorial and tips trik, The article you are reading this time with the title Android RecyclerView Step-by-Step Tutorial (Part 7) - Event Listener, we have prepared this article for you to read and download the information therein. hopefully fill posts article -, article (Part, article 7), article android, article Event, article Listener, article RecyclerView, article Step-by-Step, article Tutorial, we can write this you understand. Well, happy reading.

Title : Android RecyclerView Step-by-Step Tutorial (Part 7) - Event Listener
link : Android RecyclerView Step-by-Step Tutorial (Part 7) - Event Listener

Baca juga


Android RecyclerView Step-by-Step Tutorial (Part 7) - Event Listener

Hello everyone! My name is Oum Saokosal.

Today, we will continue our lesson about androidRecyclerView.

We will talk about Event Listener.

You want to click on the first item you wantto go to another activity to display all the information about the item.

So, this is my YouTube channel.

You can find good lessons about Androids andsome other things.

Oum Saokosal.

Facebook page, kosalgeek.

Twitter and GitHub.

And in previous lesson, we used one of mylibrary to cnovert the JSON to ArrayList in the GitHub as well.

So, the purpose of this video, it's like youhave this and then you click on that item and then you will show the whole data of theitem.

Impress you, you come to this video just forthe plus sign, I suggest you to go to YouTube and you can just type Android RecyclerViewand my name.

You're going to see this.

This is the English version and this is itsKhmer version.

I done a little bit similar so that you canfind the source code in the thing in part three, no impact five.

Just go down here and you will see the sourcecode here.

You can continue from there.

This is our previous lesson that we can clickon open.

Showed it at the item like that.

Now, we want to click on the item.

So, it's very easy actually.

First, you want to know where you want toclick, right? So, you go to your adapter here.

And then, you will see the binding here andyou want to click on the image, right? Call it, image, IV, no, holder Iv Image URL.

No, no, no, sorry.

It's just holder, ivImage URL.

This one, image thing and then, you want tostep on click listener.

Actually, it's not image URL, it's just image.

I confused myself.

So, I should rename that to image, not imageURL.

Here is the real image.

So, I have the refractor.

Just delete that.

Just give image.

I confused myself.

Okay, now, the image.

You want to click on the image and then yousay this, no, new but not this and then control space.

Then, you will see the even here.

This is where you want to set the accent forthe clicking.

You want to have Toast.

Make like that.

And you can use to context here.

It's context.

And click.

So, let's run it.

If you don't know and you don't understandthis, I think you should go back to the previous one.

Because I just followed the two other, previousmaterial.

I cannot explain it again.

We're going to waste a lot of time for that.

And in this video, we should just focus onthe Event Listener.

So, now, let's see.

See that? Image clicked.

So, you click on item one here.

It's going to show the item one.

It's item two.

Okay, so how to deal with the specific item.

Actually it's very easy.

Because we got the product here already.

& if you want to make sure, just refract tosomething like, selected product.

It's better.

Now, it's selected.

So, this is the product that you selected.

And you want to show something.

Let's say, it was product name.

Now, you want to declare it final becauseyou used in selected product inside that.

And only first class.

So, it should be final over here.

So, I think it's running.

Not completed.

Wait a little bit.

Okay, it looks like it's going to run now.

Yes, see it again.

Yes, new item.

It's just the title here.

Let's go down a little bit.

Let's see the cat here.

Okay, now it's a cat.

That is the item that you want, the product.

You want to send this data to another page.

Another duty.

So, let's create another activity here.

And you choose activity.

Okay, slowly.

Raising activity here.

And rename it to Detail Activity.

And the hierarchical is very important.

You want to have the back button, so you choosethis when you click back, you can come back to the main page.

And here, you want to have like, Image, title,data.

So, you have to look back in your database.

So, you can go back and what is the database? I got my database now, so let's see the wholething.

That's good customer product for that.

So, let' go back a little bit here to seecustomer here and connection.

So, the database is customer as well.

So, it's my customer here.

So, product here.

Structure is just one image.

You know, name.

So you want to have this as well.

Quantity, Price.

Just go to here and go to content detail here.

You want to have one image.

ImageView.

Drag and make sure that the arrow is exactly like me.

Like this and usually I go to code and thenadd some image there after default here.

Drawable pp.

That is the image.

Scale type, Centercrop.

So, the height 300 DP.

It's too big and you can scale down yourself.

And add some text here.

Just maybe, one is enough.

Maybe another one, down here.

That looks good.

Just rename it.

IVimage.

Check it and just, it's fine.

Maybe the Prize already happened.

Sorry for the noise.

Let's go back to the activity.

So, you want to send the data from here.

So, first you have to make sure that the classproduct has to implement Serializable.

Without that, you cannot send the whole object.

Here, intent.

You want to go from, new intent.

You want to have from context and go to intentand do to the class.

That's good.

In inputextra, put.

Just call product.

This is the data you want to select.

StartActivity.

So, now, you cannot start TV because thereis no, the product at the matter is not the activity.

So, I think you can use another thing.

Maybe, View but we had to get a view somewhere.

Where is it? I think over here.

We can use Holder.

No, I think there is a trick here becauseyou want to send the data from one activity to another and here is not the activity.

Let's see.

Maybe we can just copy.

So, now, view can be used anywhere here.

So, View.

Activity, No.

Let me see.

Which one? Is it the layout? Is it the�? Let me check.

I forgot it.

Okay, found in four.

Put the context here.

You know, the main activity that we got itfrom here.

Set it from outside or the context is theplace where you want to start the activity.

Then you can start it.

So, this is the code that you want to some,send the data from this.

Like, even click on the image and then youput the whole object that we got from the selected here.

And then we use the context here to startthe activity.

And you go to the detail right here.

Just call, check it a little bit like here,get intent, get Serializable extra.

Which is the key? Here is the key.

And product null.

It means that sometime you didn't send a datalike the product that you didn't send.

Or misspelled it like product with a P capitaland you'll see it with the wrong key.

With small P like that, so guys have to becareful on that.

So, we have to make sure that it's not now.

Then, we can get the data.

So, let's just call it text, this one is this.

So, you can get the data, this product righthere.

But we have to cast it as well before, justlike a general object, we have the product for that now.

Name.

Okay, let's see.

Maybe this one is good.

There's some error here.

Let's see, what is the error? Calling start activity from outside.

Yeah, I forgot one thing here.

So, we want to set this because we use contextoutside, so the error is not real error.

I guess it's trying to tell you that justgo and you go code down there and set it.

Set Flags something, just pass the code.

But I think, yes something like this.

It's going to work.

Get away.

So, run again.

Let's see, over here, cat and you see thewhole thing.

It's a cat now and it's just full image beforetext.

You get the data from the phone.

And put it into the cell activity.

ImageView, IVimage.

Sorry for the noise.

TVprice.

IVimage.

FindView.

IVimage.

And it's wrong again.

But this one must be TextView.

You need Picasso.

So the code for Picasso is here.

It's helping.

You just have to code here.

And the context is this and the URL is theproduct that you need the full URL here because, you need to note the IP.

Holder is not the holder anymore.

Just the IVimage.

And the text, TVtitle and product, just name.

Just name the last one price.

But the price is like, an integer and vowel,a number, I'm not sure about it.

Maybe you can just put dollar sign in frontof it.

I think it's going to work.

And it's all about that.

Let's wait a little bit.

It's running now.

Okay, Item number three is the cat.

The title is cat and the price is five dollar.

So, that's all.

Now, you can reduce the, even click on theitem and then you can send the data from one of this to another and then you can receivethat and then put into the detail page and if you want to have a lot of data.

Like here, lot of image, I suggest you toput the scroll view because maybe this one is okay but when you rotate it, you're goingto have some problem.

So, you can put the scroll or maybe just,I can do it for you.

It's not a big deal.

Just cut this and then put the scroll viewand then here, match parent.

And the scroll view needs another layout andmatch parent.

And put something over here and now you havea nice scroll view.

Even though there are like size differentbut now you can see the opening here.

You want to get rid of it, you can just doit in the activity here.

Just delete the old one, leave it or maybeyou want to move to somewhere.

That's it for this video and we will see youin the next one.



Thus Article Android RecyclerView Step-by-Step Tutorial (Part 7) - Event Listener

That article Android RecyclerView Step-by-Step Tutorial (Part 7) - Event Listener This time, hopefully we can give you all of the benefits. Well, I'll see you in another article post.

You now read the article Android RecyclerView Step-by-Step Tutorial (Part 7) - Event Listener the link address http://svedda79.blogspot.com/2016/08/android-recyclerview-step-by-step.html

0 Response to "Android RecyclerView Step-by-Step Tutorial (Part 7) - Event Listener"

Post a Comment