我想覆盖从设置页面到应用程序屏幕的时间。我附加了2张图片,其中一张是需要覆盖时间的应用程序屏幕,第二张是设置页面This is the 1st picture i.e; app screen where time need to be override here.。如果我想更改为下午5:00,我该怎么办?This is the second image which is the settings page where when i input time here the time need to change in the first image
答案 0 :(得分:0)
所以这就是我认为你想要实现的目标,
1.在您的应用中有一页(即第一张图片)以显示当前时间 2.您希望该页面根据手机上设置的时间进行更改。
使用以下代码获取系统时间
Calendar c = Calendar.getInstance();
SimpleDateFormat df = new SimpleDateFormat("HH:mm a");
String formattedTime = df.format(c.getTime());
// Now formattedDate have current date/time
TextView.setText(formattedTime); //set it to your time view
使用上面的代码,您可以让视图设置系统时间的时间。 PS确保您也在活动的onResume()方法中设置时间