Android RecyclerView onItemClick : Android Material Design Tutorials [HD 1080p]
This Android Tutorial shows you how to start an Activity from your Navigation Drawer using the RecyclerView's onClick. We demonstrate 2 ways of handling the ...
+Dhaval Chheda first of all, wish you a very happy new year and may you take the initiative to turn this year into a prosperous one :) second of all, i am adding a new android course coming up here in 10 days https://goo.gl/JqAUyg stay tuned, I ll post an update about it here https://goo.gl/ASF501
Hey, what if FragmentManager decides it wants to recreate the fragment?
Doesn't this cause a memory leak because it's referenced by the adapter and
so the old instance can't be garbage collected? I know this is a problem if
you hold onto an instance of an activity which can be destroyed at any time
when a configuration change occurs. It may not ever happen with fragments,
but I guess I would rather be safe and only use a WeakReference on the
fragment as a Clicklistener.
+slidenerd Alright, sorry. I didn't mean to sound condescending. The problem I'm referring to is basically this: If say, for example, you start an Async Task from an Activity, you would need a reference to that Activity from within the Async Task to call it back with results when the task is done. Now, the obvious solution would be to just pass the Activity along to the Async Task which in turn holds a reference to it until the task is done. That works fine as long as the Activity is alive. However, if a configuration change occurs, for example because the device is rotated, the entire Activity is destroyed and recreated by the system. Now, if that recreation process takes place while the AsyncTask is running and holds a reference to the Activity, it cannot be destroyed and stays alive basically forever, yet another Activity is created anyway. Thus, you end up with two activities one of which is never used again, but also isn't garbage collected because the async task refers to it. Now, a common way to solve this issue is to wrap the Activity inside a WeakReference object which basically tells the garbage collector that the object can be destroyed at any time, so you can avoid a memory leak that way.This is what I'm talking about: //stackoverflow.com/questions/18297378/weakreference-asynctask-pattern-in-androidNow, in a similar way, I was wondering if the Fragment might leak if you pass it as a ClickListener to the Adapter which then strongly holds a reference to it. If said Fragment is destroyed and recreated, the old Fragment object might not be garbage collected because the Adapter is still refering to it. So I was asking whether this is an issue here. But I don't think it is because you're recreating the adapter and resetting the clicklistener in the onCreateView method, so I guess this whole wall of text was all for nothing. :D Oh, well, happy new year and keep up your good work! :)
Hi i was following this video, and i dont know why, but im having an error
on this part
if(clickListner!=null) {
clickListner.itemClicked(v.getPosition());
}
and the error is on getPosition, it says "can not resolve method
getPosition"
+slidenerd yea I solved this problem. but there's another thing.. I want to open multiple activities from this drawer. Like separate activity for each element of navigation drawer. How can I do that? Plz reply A.S.A.
+സനൽ sure, thanks, can you please rate my videos 5 star here if you didnt do so //udemy.com/u/vivekramesh2 thanks in advance :)
How To Move Contacts from Android to Apple | Transfer Contacts Tutorial | Easiest Way
How To Move Contacts from Android to Apple | Transfer Contacts Tutorial | Easiest Way Heres a simple tutorial on how to transfer contacts from android to apple ...