I have 2 layout files (activity_test.xml) and (content.xml) and one java file (ActivityTest.java)  ActivityTest.java set its content layout from (activity_test.xml) as shown  ActivityTest.java  @Override protected void onCreate(Bundle savedInstanceState) { .....................  super.onCreate(savedInstanceState); setContentView(R.layout.activity_test);  }   activity_test.xml contains a recyclerView as shown  activity_test.xml  &lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;androidx.constraintlayout.widget.ConstraintLayout  xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="wrap_content" android:fitsSystemWindows="true" tools:context=".ActivityTest"&gt;  ............ some views ...........  &lt;androidx.recyclerview.widget.RecyclerView  android:layout_width="match_parent"  android:layout_height="match_parent"  android:id="@+id/recycler_view2"  android:layout_marginTop="30dp"  android:layout_alignParentBottom="true"  android:scrollbars="vertical"  app:layout_constraintBottom_toBottomOf="parent"  app:layout_constraintHorizontal_bias="0.0"  app:layout_constraintLeft_toLeftOf="parent"  app:layout_constraintRight_toRightOf="parent"  app:layout_constraintTop_toTopOf="parent"  app:layout_constraintVertical_bias="0.0"             /&gt;   I have a RecyclerViewAdapter that inflates the (content.xml) layout as shown  RecyclerViewAdapter  public class RecyclerViewAdapter extends RecyclerView.Adapter&lt;RecyclerViewAdapter.MyViewHolder&gt; {  ............. @NonNull @Override public MyViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {     View itemView = LayoutInflater.from(parent.getContext())             .inflate(R.layout.content, parent, false);     return new RecyclerViewAdapter.MyViewHolder(itemView); } }   Here is the content.xml  content.xml  &lt;ScrollView xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="wrap_content" tools:context=".TestActivity"&gt;  &lt;RelativeLayout android:layout_width="match_parent" android:layout_height="wrap_content" &gt;  ...........   &lt;ImageView   android:layout_width="wrap_content"   android:layout_height="wrap_content"   android:id="@+id/save"   android:src="@drawable/outline_share_black_48dp"   android:layout_toLeftOf="@+id/savePhoto"   android:layout_marginTop="5dp"   android:layout_marginRight="20dp"   android:clickable="true"   android:onClick="saveIntent"             /&gt;          The problem - Setting a click Listener on the ImageView above with the id(save) throws that error.  ClickEvents such as - OnClickListener, OnTouchLlistener, setVisibility all throws the error - "Attempt to invoke virtual method 'void android.widget.ImageView.setVisibility(int)' on a null object reference"  e.g   MainActivity.java  ..........  private ImageView save_icon;  ..........  super.onCreate(savedInstanceState); setContentView(R.layout.activity_test);  ............. save_icon = findViewById(R.id.save); ........  public void saveIntent(View view){     if(view.getId() == R.id.savePhotoIcon){          save_icon.setImageResource(R.drawable.outline_bookmark_black_48dp);     }  }   I want to change the image src of the ImageView to another Image onClick  I tried doing this without xml - (android:Clickable and android:OnClick) but still throwing thesame error.  Most likely the id(save) in content.xml is returning a null value because it wasnt't used as the setContentView layout in onCreate in MainActivity.Java file.  When I tried thesame thing on a view from (activity_test.xml), it works.   Although, Actions such as - Displaying a toast message, New Intent all works. e.g   public void saveIntent(View view){     Intent intent = new Intent(ActivityTest.this, AnotherActivity.class);     startActivity(intent); }
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?
Drush from GitHub stopped working Unit testing a method that calls another method Batch/Multi rename only files with a specific number range I have a situation where I have the following:  file01.ext . . . file99.ext file100.ext . . .   And I want to (using rename ) insert the '0' for the files 01-99 (so that they become 000-099) but not modify files larger than 100. Which expression should I use and what is a good source on learning regular expressions such as these?   On Windows I would have used Total Commander's multi rename function which has a very simple renaming syntax. Are there some good alternatives for that tool (multi-rename) for Ubuntu? Is JavaScript's "new" keyword considered harmful? In another , a user pointed out that the new keyword was dangerous to use and proposed a solution to object creation that did not use new. I didn't believe that was true, mostly because I've used Prototype, Scriptaculous and other excellent JavaScript libraries, and everyone of them used the new keyword.  In spite of that, yesterday I was watching Douglas Crockford's talk at YUI theater and he said the exactly same thing, that he didn't use the new keyword anymore in his code ().  Is it 'bad' to use the new keyword? What are the advantages and disadvantages of using it? Is there a way to set an "Adventure Mode Boundary" in Minecraft? Is there a way to set an "Adventure Mode Boundary" in Minecraft?  I am trying to create this village where players can spawn in, and then set out to explore the world and build and do normal minecraft stuff. I don't want them to destroy this village, so I want them to be in adventure mode when they are in the village and then switch them to survival when they leave, and vice-versa. When they return to the village, they get switched back to adventure mode.  In other words, I want to set an "Adventure Mode Boundary" to protect buildings. I am working without mods. I am hoping there is an simple way using command blocks. Why do we not use the definite article in "Where can I find the room 401?" Last week in college, a student [with a thick South Asian accent] asked me:     "Excuse me, where can I find the room 401?".   I realized that to my native English ears, the word "the" sounded non-native. This had me realize that we sometimes use no article.  I am learning French; in French, we seem to always use some kind of article before nouns. It surprised me, at that moment, to realize that English doesn't always do the same! (That, and using the definite article in "the room 401" seems to make sense if I think about when definite articles are used).  Is there a grammatical name or concept for this "no article" aspect of our language? Are there any websites that can explain this to me? How do I determine the size of my array in C? How do I determine the size of my array in C?   That is, the number of elements the array can hold? Non numbered chapter* header issue Zlib-compatible compression streams? Record screen, microphone and web camera in Ubuntu 17.10 (Wayland Session) General Relativity Equivalence Is Einsteins Equivalence theorem in General Relativity correct? It seems to me that it neglects the fact that gravitational acceleration depends upon separation distance squared, thus neglecting the effect of tidal forces.   For example, as I sit on earth, I experience the affect of earth's gravity; Although the acceleration on my head is slightly less than the acceleration acting on my feet. If I make the claim that my frame is equivalent to me being in a space ship traveling at g, doesn't that mean my whole body is accelerating at g uniformly? This is contrary to the previous statement though. How many seconds count until bomb detonates in Counter Strike? In Counter-Strike, is there any count (in seconds/minutes) until the bomb explode when it's first set-up? And can the timing be modified? A message may be accompanied with a digital signature, a MAC or a message hash, as a proof of some kind.  Which assurances does each primitive provide to the recipient?  What kind of keys are needed? Two Circles and Tangents from Their Centers Problem Let $\Gamma_1$ and $\Gamma_2$ be two non overlapping circles with centers $O_1$ and $O_2$ respectively. From $O_1$, draw the two tangents to $\Gamma_2$ and let them intersect $\Gamma_1$ at points $A$ and $B$. Similarly, from $O_2$, draw the two tangents to $\Gamma_1$ and let them intersect $\Gamma_2$ at points $C$ and $D$.  Prove that $AB=CD$.  I've done some extensive angle chasing on this but have been unable to make any real progress. Can't decide whether $ABCD$ is supposed to be rectangle (as in my diagrams), a parallelogram or even a trapezium. There is a homothety taking one circle to the other but as far as I can see this doesn't help as we don't have a clearly defined center to this.  Any help/hints would be greatly appreciated. All Stack Exchange data dumps The original ClearBits link to the September 2011 data dump has broken. How can I access it and other previous data dumps? The Internet Archive only has . How do I get Siri to pronounce my name correctly? Siri doesn't pronounce my name correctly. I tried editing the phonetic spelling as it says on many sites, but it doesn't fix the problem. How do I fix this problem? Can a git submodule be created retroactively? The story:   Question posted on Programmers (let's call it ), Same question posted on Code Review (let's call it ), I migrate Q1 to Code Review, Someone notices that Q1 is a duplicate of Q2 and votes to close, I notice the duplicate notice and the auto-generated comment and also try to vote to close, but can't. No error message, nothing, it just doesn't work.   And then I notice that Q2 no longer exists ("voluntarily removed by its author"). My guess is the OP also noticed the duplicate vote, realized how messy cross posts are and decided to be a good citizen and delete one of the two questions. He picked the wrong one though, and now we're left with a duplicate notice pointing to a non existent question and an unresponsive dialog.  It's a mess ;) A weird and rare mess, but still a mess. What can we do about it? In  related question (), the OP asks if it is grammatical to use the definite article before phrases like Advanced programming in Java whitepaper and Microsoft Office 2010 product. The accepted answer by @Kosmonaut was:     Yes, it is. This is because the "Advanced programming in Java"   whitepaper phrase forms a syntactic unit, with whitepaper as the head   of the unit. The definite article for a phrase always corresponds to   the head of the phrase, so using the definite (or indefinite) article   for these phrases makes perfect sense and is correct English.   My question is whether the same answer applies to phrases like Heathrow Airport, Hyde Park,  Waterloo Station, Edgware Road and Parliament Square. I ask becase it seems to me that airport, park and station, etc. sound like they are part of the proper noun itself, and not simply a common noun. Moreover, I think the head of the unit in these cases would be the place name (first noun) and not the place type (second noun). If that's true, then I assume that no definite article should precede these phrases. Is that correct? Show $\lim_{n \to \infty} n^{-1} E \left( \frac{1}{X}1_{[X>n^{-1}]} \right) =0$ Suppose $X$ is a non-negative random variable satisfying  \begin{align*} P[0 \le X &lt; \infty ]=1. \end{align*} Show   a)  \begin{align*} \lim_{n \to \infty} n E \left( \frac{1}{X}1_{[X&gt;n]} \right) =0 \end{align*} b)  \begin{align*} \lim_{n \to \infty} n^{-1} E \left( \frac{1}{X}1_{[X&gt;n^{-1}]} \right) =0 \end{align*}  What I did  I showed part a) already here is the proof:  \begin{align*} n E \left( \frac{1}{X}1_{[X&gt;n]} \right) \le n E \left( \frac{1}{n}1_{[X&gt;n]} \right)=n\cdot\frac{1}{n}P[X&gt;n]=P[X&gt;n] \end{align*} So $\lim_{n \to \infty} n E \left( \frac{1}{X}1_{[X&gt;n]} \right) \le \lim_{n \to \infty} P[X&gt;n]=0$.  What about part b)? The same techniques no longer works.  I was thinking that  \begin{align*} \lim_{n \to \infty} n E \left( \frac{1}{X}1_{[X&gt;n]} \right) \le \lim_{n \to \infty} n E \left( \frac{1}{X} \right) \le 0 \end{align*} but I am not sure that $E \left( \frac{1}{X} \right) &lt; \infty$