我将如何显示在窗口小部件的EditText的文本的当前日期在运行时动态?
How would I display the current date in the text of a EditText widget dynamically at runtime?
谢谢帕特里克
Thanks patrick
如果您的EditText在XML文件中声明,你在code这样的检索它
If your EditText is declared in the xml file, you have to retrieve it in the code like this
EditText editText = (EditText) findViewById( R.id.your_edittext_id );
然后你就可以轻松地将其与当前的日期更新
Then you can easily update it with the current date
SimpleDateFormat sdf = new SimpleDateFormat( "yyyy/MM/dd" );
editText.setText( sdf.format( new Date() ));