title: onClick not working in fragment. (using imageview as a button)
body: <p>I want to implement onclick in my fragment to change fragment.</p>
  <p>Here is this function:</p>
  <pre><code>  @Override
  public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
      View view = inflater.inflate(R.layout.fragment_one, container, false);
  
      super.onViewCreated(view, savedInstanceState);
  
  
      imageView9 = (ImageView)view.findViewById(R.id.imageView3);
  
      imageView9.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View view) {
              // Create new fragment and transaction
              Fragment newFragment = new FragEditProfile();
              // consider using Java coding conventions (upper first char class names!!!)
              FragmentTransaction transaction = getFragmentManager().beginTransaction();
  
              // Replace whatever is in the fragment_container view with this fragment,
              // and add the transaction to the back stack
              transaction.replace(R.id.content_frame_container, newFragment);
              transaction.addToBackStack(null);
  
              // Commit the transaction
              transaction.commit();
          }
  
      });
  </code></pre>
  <p>It's 'clicking' cause I hear the typical button sound. But i'm getting this error when clicks:</p>
  <pre><code>ssl=0xaf840c00 cert_verify_callback x509_store_ctx=0xa17d2280 arg=0x0
  ssl=0xaf840c00 cert_verify_callback calling verifyCertificateChain authMethod=ECDHE_RSA
  </code></pre>
  <p>Here is my main_activity layout:</p>
  <pre><code>&lt;android.support.v4.widget.DrawerLayout
      xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
      android:id=&quot;@+id/drawer_layout&quot;
      android:layout_width=&quot;match_parent&quot;
      android:layout_height=&quot;match_parent&quot;
      android:background=&quot;#000&quot; &gt;
      &lt;android.support.v7.widget.Toolbar
          android:id=&quot;@+id/toolbarInner&quot;
          android:layout_width=&quot;match_parent&quot;
          android:layout_height=&quot;?attr/actionBarSize&quot;&gt;
  
      &lt;/android.support.v7.widget.Toolbar&gt;
  
  
  
  
      &lt;RelativeLayout
          android:layout_width=&quot;match_parent&quot;
          android:layout_height=&quot;match_parent&quot;&gt;
  
          &lt;RelativeLayout android:id=&quot;@+id/content_frame_container&quot;
              android:layout_width=&quot;match_parent&quot;
              android:layout_height=&quot;match_parent&quot;
              android:background=&quot;#212&quot;
              android:layout_below=&quot;@+id/toolbar_app_bar_layout&quot;&gt;
  
  
  
  
              &lt;FrameLayout
                  android:id=&quot;@+id/content_frame&quot;
                  android:layout_width=&quot;match_parent&quot;
                  android:layout_height=&quot;match_parent&quot;&gt;
              &lt;/FrameLayout&gt;
  
          &lt;/RelativeLayout&gt;
  
          &lt;android.support.design.widget.AppBarLayout
              android:id=&quot;@+id/toolbar_app_bar_layout&quot;
              android:layout_width=&quot;match_parent&quot;
              android:layout_height=&quot;wrap_content&quot;
              android:theme=&quot;@style/ThemeOverlay.AppCompat.Dark.ActionBar&quot;
              &gt;
  
              &lt;LinearLayout
                  android:layout_width=&quot;match_parent&quot;
                  android:layout_height=&quot;wrap_content&quot;
  
                  android:gravity=&quot;center&quot;
                  android:orientation=&quot;vertical&quot; &gt;
  
                  &lt;include
                      android:layout_width=&quot;match_parent&quot;
                      android:layout_height=&quot;wrap_content&quot;
                      layout=&quot;@layout/top_points_bar&quot; /&gt;
              &lt;/LinearLayout&gt;
              &lt;android.support.design.widget.TabLayout
                  xmlns:app=&quot;http://schemas.android.com/apk/res-auto&quot;
                  android:id=&quot;@+id/sliding_tabs&quot;
                  android:layout_width=&quot;match_parent&quot;
                  android:layout_height=&quot;wrap_content&quot;
                  android:layout_below=&quot;@+id/toolbar&quot;
                  app:tabMode=&quot;scrollable&quot;
                  app:paddingStart=&quot;16dp&quot;
                  app:tabPaddingStart=&quot;16dp&quot;
                  app:tabPaddingEnd=&quot;16dp&quot;
                  app:tabMinWidth=&quot;96dp&quot;
                  app:tabGravity=&quot;center&quot; /&gt;
  
          &lt;/android.support.design.widget.AppBarLayout&gt;
  
          &lt;android.support.v4.view.ViewPager
              android:id=&quot;@+id/pager&quot;
              android:layout_width=&quot;fill_parent&quot;
              android:layout_height=&quot;match_parent&quot;
              android:layout_alignParentBottom=&quot;true&quot;
              android:layout_alignParentLeft=&quot;true&quot;
              android:layout_alignParentStart=&quot;true&quot; /&gt;
  
  
      &lt;/RelativeLayout&gt;
  
      &lt;android.support.design.widget.NavigationView
          xmlns:app=&quot;http://schemas.android.com/apk/res-auto&quot;
          android:id=&quot;@+id/navigation_view&quot;
  
          android:layout_width=&quot;match_parent&quot;
          android:layout_height=&quot;wrap_content&quot;
          android:layout_gravity=&quot;start&quot;
          android:background=&quot;@color/md_brown_100&quot;
          app:menu=&quot;@menu/menu_drawer&quot;
          android:textColor=&quot;@color/okurwa&quot;
          app:theme=&quot;@style/MyTabStyle&quot;
          app:headerLayout=&quot;@layout/nav_drawer_header&quot;
          app:itemTextAppearance=&quot;@style/MyTabTextStyle&quot;
          android:clipToPadding=&quot;false&quot;&gt;
  
  
  
  
  
          &lt;TextView
              android:id=&quot;@+id/nav_drawer_wallet_id&quot;
              android:layout_width=&quot;177dp&quot;
              android:layout_height=&quot;wrap_content&quot;
              android:textSize=&quot;15sp&quot;
              android:layout_marginTop=&quot;8dp&quot;
              android:layout_marginLeft=&quot;16dp&quot;
              android:layout_marginBottom=&quot;8dp&quot;/&gt;
  
          &lt;TextView
              android:id=&quot;@+id/nav_drawer_total_credits&quot;
              android:layout_width=&quot;182dp&quot;
              android:layout_height=&quot;wrap_content&quot;
              android:textSize=&quot;16sp&quot;
              android:layout_marginTop=&quot;200dp&quot;
              android:layout_marginLeft=&quot;16dp&quot; /&gt;
  
          &lt;TextView
              android:id=&quot;@+id/nav_drawer_username&quot;
              android:layout_width=&quot;wrap_content&quot;
              android:layout_height=&quot;wrap_content&quot;
              android:layout_gravity=&quot;center_horizontal&quot;
              android:textSize=&quot;22sp&quot;
              android:layout_marginTop=&quot;150dp&quot;/&gt;
  
  
  
          &lt;!--&lt;FrameLayout--&gt;
          &lt;!--android:layout_width=&quot;match_parent&quot;--&gt;
          &lt;!--android:layout_height=&quot;wrap_content&quot;--&gt;
          &lt;!--android:layout_gravity=&quot;bottom&quot;--&gt;
          &lt;!--android:background=&quot;@color/md_white_1000&quot;--&gt;
          &lt;!--android:elevation=&quot;4dp&quot;--&gt;
          &lt;!--android:layout_marginBottom=&quot;-96dp&quot;&gt;--&gt;
  
          &lt;!--&lt;Button android:id=&quot;@+id/navigation_button_footer&quot;--&gt;
          &lt;!--android:layout_width=&quot;match_parent&quot;--&gt;
          &lt;!--android:layout_height=&quot;match_parent&quot;--&gt;
          &lt;!--android:text=&quot;&quot;--&gt;
          &lt;!--android:textSize=&quot;13sp&quot;--&gt;
          &lt;!--android:textColor=&quot;@color/md_grey_800&quot;--&gt;
          &lt;!--android:lines=&quot;3&quot;--&gt;
          &lt;!--android:gravity=&quot;center&quot;--&gt;
          &lt;!--style=&quot;@style/Widget.AppCompat.ActionButton&quot;--&gt;
          &lt;!--android:paddingTop=&quot;20dp&quot;--&gt;
          &lt;!--android:paddingLeft=&quot;20dp&quot;--&gt;
          &lt;!--android:paddingRight=&quot;20dp&quot;--&gt;
          &lt;!--android:paddingBottom=&quot;20dp&quot;/&gt;--&gt;
  
          &lt;!--&lt;/FrameLayout&gt;--&gt;
  
      &lt;/android.support.design.widget.NavigationView&gt;
  
      &lt;RelativeLayout
          android:id=&quot;@+id/lay_connection&quot;
          android:layout_width=&quot;match_parent&quot;
          android:layout_height=&quot;match_parent&quot;
          android:layout_marginTop=&quot;@dimen/actmain_margintop&quot;
          android:background=&quot;#3c3c3c&quot;
          android:visibility=&quot;gone&quot; &gt;
  
          &lt;TextView
              android:id=&quot;@+id/text_error&quot;
              android:layout_width=&quot;wrap_content&quot;
              android:layout_height=&quot;wrap_content&quot;
              android:layout_centerHorizontal=&quot;true&quot;
              android:layout_centerVertical=&quot;true&quot;
              android:gravity=&quot;center&quot;
              android:text=&quot;@string/error_no_internet&quot;
              android:textColor=&quot;@color/md_white_1000&quot;
              android:textSize=&quot;@dimen/twentyfive&quot; /&gt;
  
  
          &lt;RelativeLayout
              android:id=&quot;@+id/lay_dialog&quot;
              android:layout_width=&quot;match_parent&quot;
              android:layout_height=&quot;match_parent&quot;
              android:visibility=&quot;gone&quot; &gt;
  
              &lt;ProgressBar
                  android:id=&quot;@+id/progressBar1&quot;
                  style=&quot;?android:attr/progressBarStyleLarge&quot;
                  android:layout_width=&quot;wrap_content&quot;
                  android:layout_height=&quot;wrap_content&quot;
                  android:layout_centerHorizontal=&quot;true&quot;
                  android:layout_centerVertical=&quot;true&quot; /&gt;
  
              &lt;TextView
                  android:id=&quot;@+id/textView2&quot;
                  android:layout_width=&quot;wrap_content&quot;
                  android:layout_height=&quot;wrap_content&quot;
                  android:layout_below=&quot;@+id/progressBar1&quot;
                  android:layout_centerHorizontal=&quot;true&quot;
                  android:text=&quot;@string/error_no_internet&quot;
                  android:textColor=&quot;@color/md_white_1000&quot;
                  android:textSize=&quot;@dimen/twentyfive&quot; /&gt;
          &lt;/RelativeLayout&gt;
      &lt;/RelativeLayout&gt;
  
  &lt;/android.support.v4.widget.DrawerLayout&gt;
  </code></pre>
  <p>Please help me guys! I see this error first time. I don't know why I'm getting this error and why it's not working. Thanks Stack's Community!</p>
  <h1>EDIT</h1>
  <p>This is full code of this fragment:</p>
  <pre><code>/**
   * Created by otsma on 12.12.2016.
   */
  
  import android.content.Context;
  import android.content.res.Resources;
  import android.os.Bundle;
  import android.support.v4.app.Fragment;
  import android.support.v4.app.FragmentTransaction;
  import android.view.LayoutInflater;
  import android.view.View;
  import android.view.ViewGroup;
  import android.view.animation.Animation;
  import android.view.animation.AnimationUtils;
  import android.widget.ImageView;
  import android.widget.TextView;
  
  import com.commonutility.PreferenceConnector;
  import com.justfashion.R;
  
  import java.util.Random;
  
  
  
  public class OneFragment extends Fragment {
      final Random rnd = new Random();
  
  
      public OneFragment() {
          // Required empty public constructor
      }
  
      private static TextView creditWallet;
  
      private String[] myString;
      private static final Random rgenerator = new Random();
      private TextView firstName, textView13,textView14,textView15,textView16,textView17,textView18;
      private Animation animShake, wbijam, load1, load2, load3, load4, load5, load6, wbijam1, wbijam2, wbijam3, wbijam4, wbijam5;
      private ImageView img, imageView9,imageView19,imageView4,imageView5,imageView6,imageView7,imageView8;
  
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
      }
  
      public static void onUpdateView(Context aiContext) {
          // TODO Auto-generated method stub
          if (aiContext != null &amp;&amp; creditWallet != null)
              creditWallet.setText(PreferenceConnector.readInteger(aiContext, PreferenceConnector.WALLETPOINTS, 0) + &quot;&quot;);
  
      }
  
      @Override
      public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
          View view = inflater.inflate(R.layout.fragment_one, container, false);
  
  
          imageView9 = (ImageView) view.findViewById(R.id.imageView3);
  
          imageView9.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View view) {
                  // Create new fragment and transaction
                  Fragment newFragment = new FragEditProfile();
                  // consider using Java coding conventions (upper first char class names!!!)
                  FragmentTransaction transaction = getFragmentManager().beginTransaction();
  
                  // Replace whatever is in the fragment_container view with this fragment,
                  // and add the transaction to the back stack
                  transaction.replace(R.id.content_frame, newFragment);
                  transaction.addToBackStack(null);
  
                  // Commit the transaction
                  transaction.commit();
  
              }
  
          });
  
  
  
  
      
  
  
          img = (ImageView)view.findViewById(R.id.imgRandom);
          imageView4 = (ImageView)view.findViewById(R.id.imageView4);
          imageView5 = (ImageView)view.findViewById(R.id.imageView5);
          imageView6 = (ImageView)view.findViewById(R.id.imageView6);
          imageView7 = (ImageView)view.findViewById(R.id.imageView7);
          imageView8 = (ImageView)view.findViewById(R.id.imageView8);
  
          firstName = (TextView)view.findViewById(R.id.imie);
  
  
          textView13 = (TextView)view.findViewById(R.id.textView13);
          textView14 = (TextView)view.findViewById(R.id.textView15);
          textView15 = (TextView)view.findViewById(R.id.textView16);
          textView16 = (TextView)view.findViewById(R.id.textView17);
          textView17 = (TextView)view.findViewById(R.id.textView18);
          textView18 = (TextView)view.findViewById(R.id.textView19);
  
          final Animation wbijam = AnimationUtils.loadAnimation(getActivity().getApplicationContext(), R.anim.wbijam);
          textView13.startAnimation(wbijam);
          final Animation wbijam1 = AnimationUtils.loadAnimation(getActivity().getApplicationContext(), R.anim.wbijam);
          textView14.startAnimation(wbijam1);
          final Animation wbijam2 = AnimationUtils.loadAnimation(getActivity().getApplicationContext(), R.anim.wbijam);
          textView15.startAnimation(wbijam2);
          final Animation wbijam3 = AnimationUtils.loadAnimation(getActivity().getApplicationContext(), R.anim.wbijam);
          textView16.startAnimation(wbijam3);
          final Animation wbijam4 = AnimationUtils.loadAnimation(getActivity().getApplicationContext(), R.anim.wbijam);
          textView17.startAnimation(wbijam4);
          final Animation wbijam5 = AnimationUtils.loadAnimation(getActivity().getApplicationContext(), R.anim.wbijam);
          textView18.startAnimation(wbijam5);
  
  
  
  
  
  
          final Animation animShake = AnimationUtils.loadAnimation(getActivity().getApplicationContext(), R.anim.shak);
          img.startAnimation(animShake);
  
  
  
          final Animation load2 = AnimationUtils.loadAnimation(getActivity().getApplicationContext(), R.anim.load2);
          imageView4.startAnimation(load2);
          final Animation load3 = AnimationUtils.loadAnimation(getActivity().getApplicationContext(), R.anim.load3);
          imageView5.startAnimation(load3);
          final Animation load4 = AnimationUtils.loadAnimation(getActivity().getApplicationContext(), R.anim.load4);
          imageView6.startAnimation(load4);
          final Animation load5 = AnimationUtils.loadAnimation(getActivity().getApplicationContext(), R.anim.load5);
          imageView7.startAnimation(load5);
          final Animation load6 = AnimationUtils.loadAnimation(getActivity().getApplicationContext(), R.anim.load6);
          imageView8.startAnimation(load6);
  
  
          firstName.setText(&quot;Hey,&quot;+&quot; &quot; +PreferenceConnector.readString(getActivity().getApplicationContext(), PreferenceConnector.FIRST_NAME, &quot;&quot;));
  
          // Inflate the layout for this fragment
  
          final ImageView img = (ImageView) view.findViewById(R.id.imgRandom);
  //  return view;
  //  ^^^^  error remove it
          Resources res = getResources();
  
          myString = res.getStringArray(R.array.myArray);
  
          String q = myString[rgenerator.nextInt(myString.length)];
  
          TextView tv = (TextView) view.findViewById(R.id.tv);
          tv.setText(q);
  
  
              // I have 3 images named img_0 to img_2, so...
          final String str = &quot;img_&quot; + rnd.nextInt(9);
          img.setImageDrawable
                  (
                          getResources().getDrawable(getResourceID(str, &quot;drawable&quot;,
                                  getActivity().getApplicationContext())
                  ));
          return view;
          // ^^^ move it here
      }
  
          // I have 3 images named img_0 to img_2, so...
  
  
  
      protected final static int getResourceID
              (final String resName, final String resType, final Context ctx) {
          final int ResourceID =
                  ctx.getResources().getIdentifier(resName, resType,
                          ctx.getApplicationInfo().packageName);
          if (ResourceID == 0) {
              throw new IllegalArgumentException
                      (
                              &quot;No resource string found with name &quot; + resName
                      );
          } else {
              return ResourceID;
          }
  
      }
  
  }
  </code></pre>