I am trying to pass a context in the the fragment onCreateVIew() method but I am getting the following error.   java.lang.NullPointerException: Attempt to invoke virtual method 'void android.support.v7.widget.RecyclerView.setLayoutManager(android.support.v7.widget.RecyclerView$LayoutManager)' on a null object reference   Here's my code   import android.content.Context; import android.os.Bundle; import android.support.annotation.Nullable; import android.support.v4.app.Fragment; import android.support.v4.widget.SwipeRefreshLayout; import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.RecyclerView; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup;   import com.zoggfrombetelgeuse.closet.MySQL.mDownloader;    public class HomeFragment extends Fragment {  public HomeFragment() {     // Required empty public constructor }    static String urlAddress = "http://localhost/my-site/dbGet.php";  @Override public View onCreateView(LayoutInflater inflater, ViewGroup container,                          Bundle savedInstanceState) {     // Inflate the layout for this fragment     View view = inflater.inflate(R.layout.fragment_home, container, false);     final RecyclerView rv = (RecyclerView) view.findViewById(R.id.card_view);     rv.setLayoutManager(new LinearLayoutManager(getActivity()));      final SwipeRefreshLayout swipeRefreshLayout = (SwipeRefreshLayout) view.findViewById(R.id.swipe_layout);      swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {          @Override         public void onRefresh() {             new mDownloader(HomeFragment.this.getActivity(), urlAddress, rv, swipeRefreshLayout).execute();         }     });      return view;  }  }   Someone please explain this error in simple language and help me fix it. I have read other questions, I used onAttach() but didn't work  HomeFragment.xml  &lt;FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context="com.zoggfrombetelgeuse.closet.HomeFragment"&gt;  &lt;!-- TODO: Update blank fragment layout --&gt; &lt;android.support.v4.widget.SwipeRefreshLayout     android:layout_height="match_parent"     android:layout_width="match_parent"     android:id="@+id/swipe_layout"&gt; &lt;android.support.v7.widget.RecyclerView     android:layout_height="wrap_content"     android:layout_width="match_parent"     android:id="@+id/recycler_view"     android:scrollbars="vertical"&gt;     &lt;/android.support.v7.widget.RecyclerView&gt;  &lt;/android.support.v4.widget.SwipeRefreshLayout&gt;    &lt;/FrameLayout&gt;
What are Null Pointer Exceptions (java.lang.NullPointerException) and what causes them?  What methods/tools can be used to determine the cause so that you stop the exception from causing the program to terminate prematurely?
Gaussian Integers and Quotient Rings Show that $\mathbb{Z}[i]/(2+3i)$ is a finite field.    By applying some isomorphisms and realizing $\mathbb{Z}[i]$ as the quotient ring of $\mathbb{Z}[x]/(x^{2}+1)$, I found that:  $\mathbb{Z}[i]/(2+3i) \cong \mathbb{Z}[x]/(x^2+1,2+3x)$  However, I run into trouble as I can't divide $x^{2}+1$ by $2+3x$ in $\mathbb{Z}[x]$. What would be another way to approach the problem?  Thanks for the help. subequations and array in braces Why do microcontrollers have so little RAM? Maybe this is more of a perceptional problem, but it seems like microcontrollers have advanced by leaps and bounds in the last 20 years, in almost all regards, higher clock speed, more peripherals, easier debugging, 32-bit cores, etc...  It is still common to see RAM in the 10's of KB (16/32&nbsp;KB).  It doesn't seem like it could be an issue of cost or size directly. Is it an issue of complexity with the RAM controller above some threshold?  Or is it just that it isn't generally required?  Looking over a parts matrix at a popular Internet supplier, I see one  with 256&nbsp;KB for less than US$8, and then for a few dollars more you can find a few more that are ROMless, but it seems pretty sparse...  I don't exactly have a need for a microcontroller with a MB of volatile storage, but it seems like somebody might... Possible Duplicate:           My name is Greg — this is Greg 's post.  If my name ended with an 's', I am aware of the proper apostrophe usage (James&nbsp;→ James'), but how should this be pronounced?  Phonetically, am I Jameses best friend or James best friend? D'Alemberts Principle to solve a Classical Mechanics problem I found this question on this very site and was curious on how to solve it using D'Alembert's Principle  .I already know how to do it by balancing the torque about toppling point so please don't post the latter as an answer . My attempt was to displace the upper sphere by $d\theta$ which gives its virtual displacement as  $rd{\theta}cos(\theta)$j(notice we are only interested in the y component becuz the only component of the applied force which is gravity in this case is the y component in the dot product the other components vanish) similarly the cylinder is also displaced $r'd{\phi}cos(\phi)$ where r' is the distance from the point of toppling of the center of mass. $r'cos(\phi)=H/2=r(1+sin(\theta))$ ,$r'sin(\phi)=R=r(1+cos(\theta))$ and $tan(\phi)=H/2R$ the equation coming from D'Alemberts principle is $mgrcos(\theta)d\theta=Mgr'cos(\phi)\phi$ I tried solving this but couldn't arrive at the right answer. Any help would be appreciated! Draw a graph in Latex with Tikz Re-install Ubuntu without losing data in home folder Can Jupiter be ignited? Our solar system itself contains two candidate "Earths"  One is Jupiter's moon Europa and another is Saturn's moon Titan. Both of them have the problem of having at low temperature as Sun's heat cannot reach them.    Jupiter is made up mostly of Hydrogen so is our Sun. Can we ignite Jupiter so that it will produce enough heat to warm these two earth like planets/satellites? What can be consequences of any of such attempt? Why is method overloading and overriding needed in java? Console flashes on launching, then closes (ms-windows) I installed blender on a windows 7 64 bit system.  I opened it one time then went to the tutorials.  in the meantime I had a power failure and when I tried to start blender again I get a dos window that closes itself then nothing.  I reinstalled Blender and get the same thing.  I am going to try to uninstall then reinstall but in the mean time, any other suggestions are welcome. What is the closest general-relativistic equivalent of a "time slice"? In a newtonian universe, one can talk of a "time slice", that is, the state of the universe at a given point in (global) time. In a "typical" classical universe, a time slice would contain enough information to fully compute the state of the universe at any other point in time, backwards or forwards.  So, disregarding what we know of quantum effects and talking purely of a general-relativistic universe, which concept is closest to a time slice? Can't open snap-store Where are the evolutionary "inbetweeners"? The problem I've always had with evolution is the actual lack of variation between animals. More specifically, the lack of observable gradual change between species.  Take for example the hammerhead shark. It obviously has a strong connection with a normal shark, but where's the "half-hammerhead" shark? Where's the species that only has a SLIGHTLY wider head?  I really doubt that a single mutation on a normal shark resulted in a head shaped like that, it had to happen gradually. Right? As far as I understand, evolution works by random mutation in a child being somehow slightly beneficial to that animal so it get's to live longer and reproduce more, eventually resulting in it's genetic material in dominating the inferior ones before it. But if it was for whatever reason beneficial to have a slightly wider head, why don't all the sharks have slightly wider heads now? On the other hand, if it wasn't beneficial, how come the hammerhead still exists?  Furthermore, I feel like some characteristics of a certain animal can't really have gradual benefits. There's a lizard that shoots blood out of it's eyes. The original ancestor certainly didn't, and I'm sure that if it's child only bled slightly from it's eyes it wouldn't really help if much in life. So for it to actually become beneficial, it seems to me that there had to be a ton of lizards that had a disadvantage of bleeding slightly. In fact, there had to be so many that they evolved even further in the same direction and kept doing that until they bled so much it's an actual benefit (sorry for this turning so gross). So why did the inbetweeners survive long enough to evolve even more, and why did they THEN die out? I have built my house in Minecraft PE, and I have a ton of fences and sticks, but I need to know how big of a perimeter I need to let me sleep at night? Yesterday, I tried to dualboot Ubuntu 16.04 onto my hard drive, creating a new partition for Ubuntu alongside my existing Windows 8. First, I disabled the fast-boot option in Windows 8, and still GRUB did not load, and it went directly to Windows boot-up. Then I did some research and found this article:     Basically, I issued the BCDEdit command in Windows, and entered in the following code:  bcdedit /set {bootmgr} path \EFI\ubuntu\grubx64.efi   When I reboot, I get a basic GRUB2 terminal, and after I type in the exit command, then a second Shell prompt appears, and after typing the exit command again, the GRUB2 menu to select the OS to boot finally appears... with only Ubuntu and Ubuntu memory test as options, not Windows 8.  After booting into Ubuntu, I tried to run the Boot-repair Utility, but that shows this following error:   How do I approach this problem? The Pastebin log is here:   Thanks for the help! I would like to find the correlation between a continuous (dependent variable) and a categorical (nominal: gender, independent variable) variable. Continuous data is not normally distributed. Before, I had computed it using the Spearman's $\rho$. However, I have been told that it is not right.  While searching on the internet, I found that the boxplot can provide an idea about how much they are associated; however, I was looking for a quantified value such as Pearson's product moment coefficient or Spearman's $\rho$. Can you please help me on how to do this? Or, inform on which method would be appropriate?  Would Point Biserial Coefficient be the right option? Induction Proof: Fibonacci Numbers Identity with Sum of Two Squares Using induction, how can I show the following identity about the fibonacci numbers? I'm having trouble with simplification when doing the induction step.  Identity: $$f_n^2 + f_{n+1}^2 = f_{2n+1}$$  I get to:  $$f_{n+1}^2 + f_{n+2}^2$$  Should I replace $f_{n+2}$ using the recursion? When I do that, I end up with the product of terms, and that just doesn't seem right. Any guidance on how to get manipulate during the induction step?  Thanks! How to use inotifywait to watch a directory for creation of files of a specific extension I have seen .      You should consider using inotifywait, as an example:  inotifywait -m /path -e create -e moved_to |     while read path action file; do         echo "The file '$file' appeared in directory '$path' via '$action'"         # do something with the file     done    My question is that, the above script watches a directory for creation of files of any type, but how do I modify the inotifywait command to report only when a file of certain type/extension is created (or moved into the directory) - e.g. it should report when any .xml file is created.  WHAT I TRIED:  I have run the inotifywait --help command, and have read the command line options. It has --exclude &lt;pattern&gt; and --excludei &lt;pattern&gt; commands to EXCLUDE files of certain types (by using regEx), but I need a way to INCLUDE just the files of a certain type/extension. How to copy metadata of Partial Sandbox into a new Developer sandbox? I Have only one license of Partial sandbox. I want to refresh it with Production. Before that I want to copy all the metadata present in the Partial sandbox into New/Existing Developer sandbox. How can do that?  Is it supported by salesforce? or are there any tools available for this requirement.  Thanks. I have installed the pimd service by means of apt. This comes with an upstream systemd unit file (/lib/systemd/system/pimd.service).  I want the service to be restarted when for some reason it gets killed, hence I wish to add the line Restart = always in the unit file.   However, I don’t want to modify the upstream unit file.  Is there any workaround for this?