I've spent hours attempting to debug this code. Basically I have MainActivity with the default code you get after starting a new project. And this is my MainActivityFragment:  package app.xxxx.github.io.sunshine;  import android.os.Bundle; import android.support.v4.app.Fragment; import android.app.Activity; import android.support.v4.app.FragmentActivity; import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ArrayAdapter; import android.widget.ListView;  import java.util.Arrays; import java.util.List; public class MainActivityFragment extends Fragment {      public MainActivityFragment() {     }      @Override     public View onCreateView(LayoutInflater inflater, ViewGroup container,                              Bundle savedInstanceState) {         String[] fakeData = new String[]{                 "Today - Sunny - 88/63",                 "Tomorrow - Foggy - 70/46",                 "Weds - Cloudy - 72/63",                 "Thurs - Rainy - 64/51",                 "Fri - Foggy - 70/46",                 "Sat - Sunny - 76/68"         };         List&lt;String&gt; weatherData = Arrays.asList(fakeData);         ArrayAdapter&lt;String&gt; myAdapter = new ArrayAdapter&lt;String&gt;(getActivity(), R.layout.list_item_forecast,                     R.id.listview_forecast, weatherData);         View rootView = inflater.inflate(R.layout.fragment_main, container, false);         ListView listview = (ListView) rootView.findViewById(R.id.listview_forecast);         listview.setAdapter(myAdapter);         return rootView;}}   As you can see, I'm just attempting to show some dummy strings to the screen.  Here is FragmentMain.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"     android:paddingBottom="@dimen/activity_vertical_margin"     android:paddingLeft="@dimen/activity_horizontal_margin"     android:paddingRight="@dimen/activity_horizontal_margin"     android:paddingTop="@dimen/activity_vertical_margin"     tools:context="app.xxxx.github.io.sunshine.MainActivityFragment"     tools:showIn="@layout/activity_main"&gt;      &lt;ListView         android:layout_width="match_parent"         android:layout_height="match_parent"         android:id="@+id/listview_forecast" /&gt;  &lt;/FrameLayout&gt;   and list_item_forecast.xml:    &lt;TextView xmlns:android="http://schemas.android.com/apk/res/android"     android:layout_width="match_parent"     android:layout_height="wrap_content"     android:minHeight="?android:attr/listPreferredItemHeight"     android:gravity="center_vertical"     android:id="@+id/list_item_forecast_textview" /&gt;   Here is what the Stack Trace says:     FATAL EXCEPTION: main                                                                                  Process: app.xxxx.github.io.sunshine, PID: 4652                                                                                  java.lang.NullPointerException: Attempt to invoke virtual method 'void   android.widget.TextView.setText(java.lang.CharSequence)' on a null   object reference   at   android.widget.ArrayAdapter.createViewFromResource(ArrayAdapter.java:399)   at android.widget.ArrayAdapter.getView(ArrayAdapter.java:369)   Sorry if it got a little bit ugly but had to give enough context for the problem. Thanks.
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?
How exactly do I tell if "A xxx of" is plural or singular? I looked up a few grammar-teaching websites (in Chinese language). The website says many people do not use the phrase "A xxx of" correctly because they do not identify the subject of the phrase correctly.   The website says phrases like "A range of; A high percentage of" is singular, while "a number of; a group of; a couple of; a total of" is plural.  Therefore according to the website, the correct sentences should be as follows.     A wide range of courses is available. ("A wide range" is the subject)      A high percentage of peptides that are made of amino acids is present   in the sample. ("A high percentage" is the subject)      A number/ group/ couple of people were killed in the earthquake.("people" is the subject )       A total of 230 employees were laid off. ("employees" is the subject)   I don't get the pattern here. All of this looks (or should I use "look"?) arbitrary to me. In fact I thought this phrase is supposed to be arbitrary and whether the phrase is plural or singular should depend on the the person's own judgment.   How do I identify the correct subject in the "A xxx of" phrase? Check whether $\sum _{m=1}^{\infty }\sum _{n=1}^{\infty }\frac{1}{\left(m+n\right)^2}$ converges or NOT? How to display a video in a web page using html,php Override route helper methods Is there any tool available for extracting the X, Y and Z coordinates from a .las file and exporting them to a .csv or similar file? How do I get Power Armor training in Fallout New Vegas? I've found some power armor, but I can't use it yet without training. I assumed that the Brotherhood of Steel would train me, if they like me enough.  I've completed the Brotherhood of Steel quest series for the overseer (the original one, I did not overthrow him), but I did not get any Power Armor training. What do I have to do to be able to wear Power Armor? How can I prove the convergence of the sequence $b_n=\sqrt[n]{x^n+y^n}$ where $x, y &gt; 0$?  Can I divide it in two cases?  Case 1: $x &gt; y$.  $$ b_n=\sqrt[n]{x^n+y^n} &lt; \sqrt[n]{x^n+x^n} = \sqrt[n]{2 \cdot x^n}=x \cdot \sqrt[n]{2} $$  Case 2: $x &lt; y$.  $$ b_n=\sqrt[n]{x^n+y^n} &lt; \sqrt[n]{y^n+y^n} = \sqrt[n]{2 \cdot y^n}=y \cdot \sqrt[n]{2}$$  Result: Does the sequence converges to $\max(x,y)$? How do I safely investigate a USB stick found in the parking lot at work? I work at an embedded software company. This morning I found a USB stick in the parking lot in front of the building. With all the stories of "dropped USB stick attacks" in mind, I'm obviously not going to just plug it into my laptop. OTOH, I'm curious to know whether this was actually an attempt to compromise our systems, or it's really just an innocent case of somebody accidentally losing a USB stick. How do I safely inspect the USB stick without risking exposure?  I'm worried not just about malware and crafted file system images; there's also stuff like power surge attacks:.  EDIT: Many of the answers seem to assume I want to keep the drive and use it afterwards. I have no interest in that at all, I know USB sticks are cheap, and that it wouldn't be mine to keep anyway. I only want to know whether this was indeed a semi-targeted attack, partly out of curiosity whether this actually happens in real life and not just in security papers, but also so that I could warn my coworkers.  I want to know how I would figure out whether the stick contains malware. And that's not just a matter of looking at the drive contents and seeing a suspicious autorun.inf or a carefully crafted corrupt file system - I very much also want a way to inspect the firmware. I sort-of expected that there were tools for extracting that and comparing to known-good or known-bad binaries. As far as I can tell, it's something like this:  damage reduction = armor / (armor + 100)   Is this accurate? How can I make all text the same font size (normal text, footnotes, acknowledgements etc.)? I have to submit a manuscript to a journal, and I just realized that they want every single part of the paper to be in 12 pt font. This includes tables text, footnotes, acknowledgements etc. Is there a way to force all text to be the same size? Some Git commands take commit ranges and one valid syntax is to separate two commit names with two dots .., and another syntax uses three dots ....  What are the differences between the two? Auto-expand TAB character in code formatting Related:       Note that this question, while related, is not the same as the ones linked.  In many cases, when people put code into questions or answers, they copy/paste the code from their editor.  If their editor is using tab characters, the formatting will be broken after the post is submitted.  For example, if a code is indented using TAB characters, then one TAB character in the beginning of a line will be treated as one level of indent and align with the left edge of the code, effectively indenting equally to 4 spaces.  However in the post editor it looks indented twice - the same as 8 spaces.  I often edit other people's posts to improve code formatting and I find this TAB issue being the biggest annoyance.  Most of the times (I think) on SO, we use 4 spaces to format/indent the code.  I think it would be an easy thing to auto-expand TAB characters inside &lt;code&gt; blocks by replacing them with 4 spaces when the post is submitted. I know there is a method for a Python list to return the first index of something:  &gt;&gt;&gt; l = [1, 2, 3] &gt;&gt;&gt; l.index(2) 1   Is there something like that for NumPy arrays? Show OPs if someone is answering, live I ask a lot of question on SO, so this recommendation/idea comes from that experience. I'm not really sure how this would fit in with the current structure of SE.   Oftentimes after asking a question, maybe after an hour or so, I end up finding the answer I needed somewhere. And it comes time for me to answer the most difficult question of all: do I delete this question, or do I keep it in case someone answers and others may benefit from it. The problem is, if I don't delete it and no one answers, my acceptance rate goes down. So usually I'll just delete it.  However, sometimes I fear that someone is typing a really really long answer to my question since itäs only been an hour, and so I imagine the nightmare that person experiences when they find out their essay will be gone to waste. Overall, this never-to-be-seen-again answer could have benefitted many people had the question remained.  Since SE has gone "live-happy" lately, where answers and comments refresh live, I thought it might be interesting if the original asker of the question (or anyone else for that matter) could see how many people are currently responding to the question (just count, not necessary to display their names). This way, if I know someone is replying, I won't delete the question, and others can benefit from it. /proc/PID/fd/X link number In "Settings" > "SD card &amp; phone storage settings" under "Internal Phone Storage" it lists "Available Space" as 13.78MB.  I'm trying to install an app that is 2.38MB.  Why do I get the "Insufficient storage available" error message?  I clearly have enough space.  If it's relevant, my phone is an LG Optimus V. List of lists changes reflected across sublists unexpectedly I needed to create a list of lists in Python, so I typed the following: my_list = [[1] * 4] * 3  The list looked like this: [[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]]    Then I changed one of the innermost values: my_list[0][0] = 5  Now my list looks like this: [[5, 1, 1, 1], [5, 1, 1, 1], [5, 1, 1, 1]]    which is not what I wanted or expected. Can someone please explain what's going on, and how to get around it? Why can't you use a single resistor for a number of LEDs in parallel instead of one each? Shorten title on each beamer slide In a beamer presentation the title is long but ok for the first slide. The problem is that when the title appears below on each slide it is very long and I would like to use here some sort of running or shorter title, how can this be done? Resize screen for Dead touch zone I have Star N7189 (5.5") with the lower zone of touch screen dead     The menu and back buttons don't work,but the physical home button works.   I tried to press hard on the edges of the screen, I tried to apply a twist from the short sides as if it were nothing but a wet towel. I did the hard reset but it did not work.  Sometimes pressing dead area, the phone takes it as menu button  As well as replacing the screen what other methods can I try? Is there any app, launcher or trick to resize the screen usable only to the working area?  P.S. a few hours after leaving it in airplane mode suddenly the touch had this problem but I do not remember if I inadvertently placed something heavy in that area of ​​the cell.