나는 실행 시간을 보여주는 TextClock 위젯을 만들었다. 요요안드로이드에서 위젯 TextClock을 사용하여 현재 날짜를 얻는 방법?
<TextClock
android:id="@+id/timerr"
android:layout_width="wrap_content"
android:layout_centerInParent="true"
android:textSize="50sp"
android:layout_height="wrap_content"
/>
레이아웃
생성 참조
textClock = (TextClock) findViewById(R.id.timerr);
모두 12 시간
걸렸고 포맷과 24 시간 방식
위한 시간
textClock.setFormat12Hour(null);
textClock.setFormat24Hour("HH:mm:ss");
2412시간,
textClock.setFormat12Hour("hh:mm:ss a");
textClock.setFormat24Hour(null);
지금, 나는 현재 날짜 동안은 시간과 함께 버튼을 클릭 얻을 필요하지만, 난 단지 시간이 아닙니다 UI에서 날짜를 표시해야합니다.
시간이 지남에 따라 날짜를 알 수 있습니다. 누군가가 도와 드리겠습니다. 미리 감사드립니다.
이 내 UI는 모습입니다 ...
http://i.stack.imgur.com/oQ5VR.png
현재 시간을 원하면 캘린더를받을 수 없습니다. 자세를 취한 다음 TextClock의 매개 변수를 설정하십시오. – JoxTraex
얻을 수있는 방법이 있기 때문에 TextClock 위젯에서 현재 날짜를 가져올 수 없습니다. 대신 Calendar 객체를 사용할 수 있습니다. https://developer.android.co.kr/reference/android/widget/TextClock.html –
날짜 = 새 날짜(); 날짜 alsoNow = Calendar.getInstance(). getTime(); String nowAsString = new SimpleDateFormat ("yyyy-MM-dd"). 형식 (현재); –