Void android.widget.imageview.setimageresource(int)' on a Null Reference(fatal error message in the log cat)
<p>Please am having issue with this null error message java.lang.NullPointerException (no error message). I really need assistance on how and where to add the appropriate code so that the application would not crash. Here is the JAVA file that i am having issues with. I am trying to create a recycler view and jpg images from my drawable folder</p>

<p>HorizontalListAdapter.java</p>

<pre><code>import android.app.Activity;
import android.graphics.Picture;
import android.os.Bundle;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;

public class HorizontalListAdapter extends RecyclerView.Adapter&lt;HorizontalListAdapter.ViewHolder&gt;
{
private Activity activity;
int[] images= {R.drawable.vb1,R.drawable.pota,R.drawable.vb1,
        R.drawable.pota,R.drawable.vb1,R.drawable.download1,R.drawable.pota};
String[] food_items={"prawan","awadhi_lucknow_biryani","eggwraps","chips","mayonnaise","companin","mixvegwrap"};


public HorizontalListAdapter(Activity activity)
{
    this.activity = activity;
}

@Override
public ViewHolder onCreateViewHolder(ViewGroup viewGroup, int viewType) {
    LayoutInflater inflater = activity.getLayoutInflater();
    View view = inflater.inflate(R.layout.item_horizontal_list, viewGroup, false);

    return new ViewHolder(view);
}

@Override
public void onBindViewHolder(HorizontalListAdapter.ViewHolder viewHolder, final int position) {
    viewHolder.imageView.setImageResource(images[position]);
    viewHolder.txtview.setText(food_items[position].toUpperCase());

    viewHolder.linearLayout.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {

            Toast.makeText(activity, "Position clicked: " + position, Toast.LENGTH_SHORT).show();
        }
    });
}

@Override
public int getItemCount() {
    return images.length;
}

/**
 * View holder to display each RecylerView item
 */
protected class ViewHolder extends RecyclerView.ViewHolder {

    private LinearLayout linearLayout;
    private ImageView imageView;
    private TextView txtview;


    public ViewHolder(View view) {
        super(view);
        imageView = (ImageView) view.findViewById(R.id.imageview);

        txtview = (TextView) view.findViewById(R.id.txtview);
        linearLayout = (LinearLayout) view.findViewById(R.id.layout);
    }
}
}
</code></pre>

<p>The second java class VerticalListAdapter.java</p>

<pre><code>import android.app.Activity;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;

 public class VerticalListAdapter extends RecyclerView.Adapter&lt;VerticalListAdapter.ViewHolder&gt; {

 private Activity activity;

 public VerticalListAdapter(Activity activity) {
    this.activity = activity;
 }
int[] images= {R.drawable.images,R.drawable.images,R.drawable.images,
        R.drawable.images,R.drawable.images,R.drawable.images,R.drawable.images};
String[] food_items={"prawan","awadhi_lucknow_biryani","eggwraps","chips","mayonnaise","companin","mixvegwrap"};
String[] cost={"Rs 200","Rs 300","Rs 150","R 320","Rs 450","Rs 120","Rs 380"};
@Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
    LayoutInflater inflater = activity.getLayoutInflater();
    View view = inflater.inflate(R.layout.item_recycler_view, parent, false);

    return new ViewHolder(view);
}

@Override
public void onBindViewHolder(ViewHolder viewHolder, final int position) {
    // if ((position + 1) % 2 == 0) {
    viewHolder.imageView.setImageResource(images[position]);
    viewHolder.txtview.setText(food_items[position].toUpperCase());
    viewHolder.txtCost.setText("Cost Per Person "+cost[position]);
    // } else {
    //  viewHolder.imageView.setImageResource(R.drawable.awadhi_lucknow_biryani);
    //}
    viewHolder.container.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Toast.makeText(activity, "Position: " + position, Toast.LENGTH_SHORT).show();
        }
    });
}

@Override
public int getItemCount() {
    return images.length;
}

/**
 * View holder to display each RecylerView item
 */
protected class ViewHolder extends RecyclerView.ViewHolder {
    private ImageView imageView;
    private TextView txtview;
    private TextView txtCost;
    private RelativeLayout container;

    public ViewHolder(View view) {
        super(view);
        imageView = (ImageView) view.findViewById(R.id.image);
        txtview = (TextView) view.findViewById(R.id.text);
        txtCost= (TextView) view.findViewById(R.id.textView);
        container = (RelativeLayout) view.findViewById(R.id.container);
    }

}
}
</code></pre>

<p>Please i need assistance with this i guess it is the int[]images causing the error i may be wrong please correct me with the right code i would use to replace and make the code work.</p>