I have a RelativeLayout
with a few TextView
as children
<RelativeLayout android:id="@+id/shift_parent_name" android:layout_width="fill_parent" android:layout_weight="0.25" > <TextView android:id="@+id/shift_parent_nametitle" android:text="@string/shift_parent_nametitle" style="@style/header_text" /> <TextView android:id="@+id/shift_parent_namefield" android:layout_alignParentRight="true" android:layout_below="@id/shift_parent_nametitle" style="@style/wrap" />
How do I go about using the RelativeLayout
as a button to react to a click event if any part of the area is pressed?
Just add a OnClickListener to your RelativeLayout
I have a RelativeLayout called "RelativeMain1". This is how i make it start Activity
RelativeLayout relativeclic1 =(RelativeLayout)findViewById(R.id.RelativeMain1); relativeclic1.setOnClickListener(new View.OnClickListener(){ @Override public void onClick(View v){ startActivityForResult(new Intent(A_My_Galaxy.this,C_Student_Book_Planet.class), 0); } });
After you add the onClickListener to your layout, it should work.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With