Note that there are some explanatory texts on larger screens.

plurals
  1. POhow to make android chronometer invisible and visible when clicked
    text
    copied!<p>I am working on app which has a titlebar with chronometer on the left and a textview centered in a RelativeLayout.</p> <p><img src="https://i.stack.imgur.com/abZX1.jpg" alt="Title bar with Chronometer and TextView"></p> <p>RelativeLayout take height of textview and fill screen width</p> <pre><code>&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/titlecontainer" android:orientation="vertical" android:padding="5dip" android:layout_height="wrap_content" android:layout_width="fill_parent" android:background="@color/titlebckgrnd"&gt; </code></pre> <p>I want to hide the chornometer when user clicks on it and unhide it user clicks again.</p> <p>How this can be achieved?</p> <p><strong>EDIT, further to the answers and comments</strong>:</p> <p>Here is the color file code</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;resources&gt; &lt;color name="titlebckgrnd"&gt;#FFD55A2E&lt;/color&gt; &lt;color name="titletext"&gt;#FFFFFFFF&lt;/color&gt; &lt;/resources&gt; </code></pre> <p>I used the following code as suggested </p> <pre><code>final TextView chron = (TextView)findViewById(R.id.chronometer); ((Chronometer) chron).start(); chron.setOnClickListener(new OnClickListener() { private boolean mToggle = true; @Override public void onClick(View v) { Log.d("Gaurav", "Invisible"); if(mToggle) { Log.d("Gaurav", String.valueOf(chron.getCurrentTextColor())); chron.setTextColor(R.color.titlebckgrnd); mToggle = false; } else { chron.setTextColor(R.color.titletext); mToogle = true; } //chronImage.setVisibility(View.VISIBLE); //v.setVisibility(View.INVISIBLE); } }); </code></pre> <p>but the result is </p> <p><img src="https://i.stack.imgur.com/EIDLb.jpg" alt="enter image description here"></p> <p>and it does not respond to any more clicks. </p> <p><strong>LogCat Results</strong> </p> <p><img src="https://i.stack.imgur.com/NN1Qa.jpg" alt="enter image description here"> <img src="https://i.stack.imgur.com/cD7PJ.jpg" alt="enter image description here"></p> <p>Even the debugger breakpoints show change in Textcolor value but color change in display does not happen.</p>
 

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