 <p>In fragment we have to read imageview in oncreateview</p> <pre><code>@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.my_frag_layout2, container); img = (ImageView)view.findViewById(R.id.imgview); img.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); startActivityForResult(intent,0); } }); return view; } </code></pre>