have a clock I want to display in a TextView.
I would have thought there was a few nice functions to do this, but I couldn\'t find anything. I ended up implementing
You can use TextClock widget provided by android
it requires minimum API level 17
https://developer.android.com/reference/android/widget/TextClock
if you want the current time in another text view
you can use the below code snippet
tClock = (TextClock) findViewById(R.id.textClock1);
tView = (TextView) findViewById(R.id.textview1);
btn = (Button)findViewById(R.id.btnGet);
btn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
tView.setText("Time: "+tClock.getText());
}
});
}