Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to change the TextView Color on click of a layout in android?
    primarykey
    data
    text
    <p>I want to change the background image and TextView Color on click of a layout .The background color is chnaging properly but my textview color is not changing.Here is my XML code :</p> <pre><code>&lt;RelativeLayout android:id="@+id/flight_relative" android:clickable="true" android:layout_width="match_parent" android:layout_height="70dp" android:layout_below="@+id/imgLogo" android:layout_marginTop="5dp" android:background="@drawable/button_effect" android:gravity="center_vertical" &gt; &lt;TextView android:id="@+id/flight_content" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignTop="@+id/flight_list_image" android:layout_marginTop="10dp" android:layout_toRightOf="@+id/flight_list_image" android:text="@string/flight_tittle" android:textColor="#152b72" android:textSize="15dp" android:textStyle="bold" /&gt; &lt;TextView android:id="@+id/content_flight" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@+id/flight_content" android:layout_toRightOf="@+id/flight_list_image" android:text="@string/flight_content" android:textColor="#2f2f2f" android:textSize="10sp" /&gt; &lt;ImageView android:id="@+id/flight_arrow" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignBottom="@+id/flight_content" android:layout_alignParentRight="true" android:src="@drawable/arrow" /&gt; &lt;ImageView android:id="@+id/flight_list_image" android:layout_width="50dip" android:layout_height="50dip" android:layout_alignParentLeft="true" android:layout_alignParentTop="true" android:padding="3dip" android:src="@drawable/flight_icon" /&gt; &lt;/RelativeLayout&gt; </code></pre> <p>Code to chnage the textview color is :</p> <pre><code>flightRelative = (RelativeLayout )findViewById(R.id.flight_relative); flightRelative.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { flight = (TextView)findViewById(R.id.flight_content); flight.setTextColor(Color.WHITE); } }); </code></pre> <p>What wrong i am doing please suggest me .For the first time it is not working on second time it is working</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload