1. DataPoint 클래스의 xValue를 long값으로 바꿔준다.
public class DataPoint {
long xValue;
int yValue;
public DataPoint(long xValue, int yValue) {
this.xValue = xValue;
this.yValue = yValue;
}
public DataPoint(){
}
public long getxValue() {
return xValue;
}
public int getyValue() {
return yValue;
}
}
참고:https://youtu.be/WcwhZztfY2g
2. SimpleDateFormat 지정해주자.
SimpleDateFormat sdf = new SimpleDateFormat("MM-dd-E HH:mm");//형식 지정
[JAVA] 자바 날짜 포맷 변경 방법(SimpleDateFormat) yyyyMMdd
Date클래스를 이용하여 현재 날짜를 출력하면 영문으로 된 날짜를 리턴한다. 특정 문자열 포맷으로 얻고 싶으면 java.text.SimpleDateFormat 클래스를 이용하면 된다. 다음은 오늘 날짜를 yyyy 년 MM월 dd일
junghn.tistory.com
3.showChart에서 다음 문구를 추가한다.
XAxis xAxis = lineChart.getXAxis();
xAxis.setValueFormatter(new ValueFormatter() {
@Override
public String getFormattedValue(float value) {
return sdf.format(new Date((long) value));
}
});
xAxis.setDrawLabels(true);
'안드로이드 노트' 카테고리의 다른 글
[안드로이드][프로젝트2] TextView 긴 문자열 생략해서 표시하기 (0) | 2022.04.07 |
---|---|
[안드로이드][프로젝트1]SharedPreferences를 이용하여 인트로 화면에서 바로 홈으로 넘어가기 (0) | 2022.03.26 |
[프로젝트1][안드로이드] 내가 Firebase와 연동한 상태로 MPAndroidchart 를 이용하여 Line Chart를 만든 법 (0) | 2022.03.24 |
[안드로이드][프로젝트1] MPAndroidChart를 활용한 LineChart 사용 (0) | 2022.03.23 |
[프로젝트1] DeleteAccount한 방법 (0) | 2022.03.22 |