title: Null Pointer Exception in LayoutInflater
body: <p>I have made Bean class in which we get &amp; set values for name &amp; image and make two other class .
     i made <code>MainActivity</code> class and <code>ListAdapterPlay</code> class, in which i want to set images in listView item .
      But it give <code>NullPointerException</code> in <code>LayoutInflater</code> </p>
  
  <pre><code>public class ListAdapterPlay extends BaseAdapter {
  // private Bean bean;
  private ArrayList&lt;Bean&gt; objarraylist;
  private Context context;
  private LayoutInflater objlayoutinflater;
  
  public ListAdapterPlay(ArrayList&lt;Bean&gt; objarraylist, Context context) {
      this.context = context;
      this.objarraylist = objarraylist;
      objlayoutinflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); //error at this line 
      // TODO Auto-generated constructor stub
  }
  
  @Override
  public int getCount() {
      // TODO Auto-generated method stub
      return 0;
  }
  
  @Override
  public Object getItem(int position) {
      // TODO Auto-generated method stub
      return position;
  }
  
  @Override
  public long getItemId(int position) {
      // TODO Auto-generated method stub
      return position;
  }
  
  @Override
  public View getView(int position, View convertView, ViewGroup parent) {
      Bean bean = (Bean) getItem(position);
      convertView = objlayoutinflater.inflate(R.layout.listviewrow,null);
      // TODO Auto-generated method stub
      TextView txt = (TextView) convertView.findViewById(R.id.textView1);
      // bean= new Bean();
      txt.setText(bean.getName());
  
      ImageView img = (ImageView) convertView.findViewById(R.id.imageView1);
      String uri = "drawable/" + bean.getImage();
      int imageResource = context.getResources().getIdentifier(uri, null,
              context.getPackageName());
      Drawable image = context.getResources().getDrawable(imageResource);
      img.setImageDrawable(image);
      // img.setBackgroundResource()
  
      return convertView;
  }
  }
  </code></pre>
  
  <p>i made <code>MainActivity</code> class as below</p>
  
  <pre><code>public class MainActivity extends Activity {
  private ArrayList&lt;Bean&gt; objarraylist;
  private  ListAdapterPlay objlistadapter;
  private ListView listview;
  private Context context;
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
      objarraylist=new ArrayList&lt;Bean&gt;();
      objarraylist.add(new Bean("RAM","ic_launcher"));
      objarraylist.add(new Bean("RAM","lion"));
      objarraylist.add(new Bean("RAM","lion"));
      objarraylist.add(new Bean("RAM","lion"));
      objarraylist.add(new Bean("RAM","lion"));
      objarraylist.add(new Bean("RAM","lion"));
      objarraylist.add(new Bean("RAM","lion"));
      objarraylist.add(new Bean("RAM","lion"));
      objarraylist.add(new Bean("RAM","lion"));
      objarraylist.add(new Bean("RAM","lion"));
      objarraylist.add(new Bean("RAM","lion"));
      objarraylist.add(new Bean("RAM","lion"));
      objarraylist.add(new Bean("RAM","lion"));
      objarraylist.add(new Bean("RAM","lion"));
  
      objlistadapter= new ListAdapterPlay(objarraylist,context);
      listview=(ListView)this.findViewById(R.id.listview1);
      listview.setAdapter(objlistadapter);
  }
  
  }
  </code></pre>
  
  <p>i want to set images in listView item but it through <code>NullPointerException</code> in <code>ListAdapterPlay</code> class.
    error is at this line </p>
  
  <pre><code>objlayoutinflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
  </code></pre>
  
  <p>I am stuck at this situation why? It give <code>NullPointerException</code>?</p>