Skip to content Skip to sidebar Skip to footer

How To Make Every Content Of A Relative Layout Clickable In Android

I have a layout: And it is called by a fragment class, I want to do something like, if I click any item inside of RelativeLayout of that xml file it will do something like, will

Solution 1:

Implement onClickListener to each and every View.

Simplest way will be

<TextView
            android:background="#CCCCCC"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Rate: ?"
            android:textColor="#FF0000"
            android:textStyle="bold"
            android:textSize="20dp"
            android:id="@+id/textView2"
            android:layout_alignBottom="@+id/gvImage"
            android:layout_alignParentLeft="true"
            android:layout_alignParentStart="true"
            onclick="executeTextViewClick" />

And in java class declare a function as follows.

publicvoidexecuteTextViewClick(View view){

//Toast here or navigate to other activity 

}

Post a Comment for "How To Make Every Content Of A Relative Layout Clickable In Android"