I am working on app which has a titlebar with chronometer on the left and a textview centered in a RelativeLayout.
RelativeLayout take height of textview and fill screen width
<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">
I want to hide the chornometer when user clicks on it and unhide it user clicks again.
How this can be achieved?
EDIT, further to the answers and comments:
Here is the color file code
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="titlebckgrnd">#FFD55A2E</color>
<color name="titletext">#FFFFFFFF</color>
</resources>
I used the following code as suggested
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);
}
});
but the result is
and it does not respond to any more clicks.
LogCat Results
Even the debugger breakpoints show change in Textcolor value but color change in display does not happen.