The Textview Name is accesed before assiging a value to it. That is causing the null pointer exception.Instead of Name.getId() specify the resource id of your custom layout like R.layout.CUSTOM_LAYOUT
The Context ctx is not getting any value assigned, it will cause a null pointer exception. Try the code below
public class CustomAdapter extends ArrayAdapter<ItemClass>{
Context ctx;
static LinearLayout CustomLayout;
static TextView Name;
ImageView Image;
public CustomAdapter(Context context, List<ItemClass> objects) {
super(context, CustomLayout.getId(),R.layout.custom_adapter_view, objects);
ctx = context;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
final ItemClass list = objects.getItem(position);
CustomLayout = new LinearLayout(ctx);
CustomLayout.setId(2);
CustomLayout.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT));
CustomLayout.setOrientation(LinearLayout.VERTICAL);
Image = new ImageView(ctx);
Image.setLayoutParams(new LayoutParams((int) (MainActivity.width*0.006),(int )(MainActivity.height*0.006)));
Image.setImageResource(R.drawable.ic_launcher);
CustomLayout.addView(Image);
Name = new TextView(ctx);
Name.setId(1);
Name.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
Name.setPadding((int) (MainActivity.width*0.0005),(int )(MainActivity.height*0.0005),(int) (MainActivity.width*0.0005),(int )(MainActivity.height*0.0005));
CustomLayout.addView(Name);
Image.setImageResource(list.getImage());
Name.setText(""+list.getName());
return CustomLayout;
}
}