title: Fragment gives null object reference on layout inflater
body: <p>I have a fragment "data" class which receives an array of string from the main activity class and sets those strings as textview inside itself. <br>
  I have a function "set" which receives string array as parameters and sets that as textview. <br> Code for fragment "data" class is -
  <br><br></p>
  
  <pre><code>public class data extends Fragment {
      @Override
      public View onCreateView(LayoutInflater inflater, ViewGroup container,
              Bundle savedInstanceState) {
          View v=inflater.inflate(R.layout.data,container,false);
          return v;
      }
  
      public void set(String[] a){
  
          LayoutInflater li=(LayoutInflater)getActivity().getLayoutInflater() // Logcat gives error at this line 
          View v=li.inflate(R.layout.data,null);
          TextView t1=(TextView)v.findViewById(R.id.textView3);
          TextView t2=(TextView)v.findViewById(R.id.textView4);
          t1.setText(a[0]);
          t2.setText(a[1]);
  
      }
   }
  </code></pre>
  
  <p><br><br>
  Log cat error is -</p>
  
  <pre><code>java.lang.NullPointerException: Attempt to invoke virtual method 'android.view.LayoutInflater android.app.Activity.getLayoutInflater()' on a null object reference
  </code></pre>
  
  <p><br><br>
  *****EDIT******<br>
  Now I am passing data using bundles instead of String array-<br>
  My data class looks like this-<br>
  public class data extends Fragment {</p>
  
  <pre><code>TextView t1,t2;
      @Override
  
      public View onCreateView(LayoutInflater inflater, ViewGroup container,
              Bundle savedInstanceState) {
          View v=inflater.inflate(R.layout.data,container,false);
           t1=(TextView)v.findViewById(R.id.textView3);
           t2=(TextView)v.findViewById(R.id.textView4);
          return v;
      }
  
      public void set(){
  
  
          t1.setText(getArguments().getString("name"));
          t2.setText(getArguments().getString("email"));
  
      }
  }
  </code></pre>
  
  <p><br>
  I am calling this set like this from my main activity<br></p>
  
  <pre><code>show.setOnClickListener(new OnClickListener(){ public void onClick(View v){
              FragmentTransaction ft=getFragmentManager().beginTransaction();
              data frag=new data();
              ft.add(R.id.ly2,frag);
              ft.commit();
              String s[]=data.show();
              Bundle b=new Bundle();
              b.putString("name",s[0]);
              b.putString("email",s[1]);
              frag.setArguments(b);
              frag.set();
  
          }});&lt;br&gt;&lt;br&gt;
  </code></pre>
  
  <p>My show function is inside another class that uses database-
  <br><br></p>
  
  <pre><code>public String[] show(){
          String[] col={"name","email"};
          Cursor c=sdb.query("book",col,null,null,null,null,null);
          c.moveToFirst();
          String d[]=new String[2];
          d[0] =c.getString(c.getColumnIndex("name"));
          d[1] =c.getString(c.getColumnIndex("email"));
          return d;
          }
  </code></pre>
  
  <p><br> Logcat now says-</p>
  
  <pre><code>java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.TextView.setText(java.lang.CharSequence)' on a null object reference
  </code></pre>
  
  <p>Kindly help.</p>