I am a newer to Android development. now I want to show current system time in a thread via textview control. I get some example and can start the thread to draw text in textview control.
but when I trid to get system current time via below link:Display the current time and date in an Android application, I got errors,The error saying:getDateTimeInstance() is undefined for the type DateFormat. Why this answer didn't work for me ? thx.
below is the code for your reference:
public class MainActivity extends Activity {
private TextView timeView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
new Thread(){
public void run(){
System.out.println("Thread is running!!");
timeView = (TextView)findViewById(R.id.textView1);
String currentDateTimeString = DateFormat.getDateTimeInstance().format(new Date());
timeView.setText("I am Fired via Non-UI thread:"+s);
}
}.start();
}