这是我的简单代码,以获取当前日期并显示在文本字段中。但是当前日期未显示我找不到任何错误。请帮助我帮助我
parameters = {
'redirect_uri': 'my redirect link',
'refresh_token': "my refresh token",
'grant_type': 'refresh_token',
'client_secret': 'my secret client',
'client_id': 'my client ID'
};
var data = new FormData();
for (var item in parameters) {
data.append(item, parameters[item]);
};
var xhr = new XMLHttpRequest();
xhr.open('POST', 'https://login.uber.com/oauth/token', true);
xhr.onload = function() {
var data = JSON.parse(this.responseText);
console.log("access_token: " + data.access_token);
var refresh_token = data.refresh_token;
console.log("refresh_token: " + refresh_token);
};
xhr.send(data);
答案 0 :(得分:1)
在代码中添加一行如果当前日期显示错误
month = calendar.get(Calendar.MONTH);
day = calendar.get(Calendar.DAY_OF_MONTH);
year1 = calendar.get(Calendar.YEAR);
Log.d("8999",month+" "+day+" "+year1);
DatePickerDialog datePickerDialog = new DatePickerDialog(SearchViewActivity.this,
new DatePickerDialog.OnDateSetListener() {
@Override
public void onDateSet(DatePicker view, int
year, int monthOfYear, int dayOfMonth) {
int curr_month = monthOfYear+1;
et_cal.setText("" + dayOfMonth + " - " + curr_month+" - " + year);
Toast.makeText(SearchViewActivity.this, "" + dayOfMonth + " - " + curr_month + " - " + year, Toast.LENGTH_SHORT).show();
}
},year1,month,day);
datePickerDialog.show();
如果日期没有显示,那么请提供您的XML布局文件,然后我详细说明。
答案 1 :(得分:0)
您的DatePickerDialog
似乎没有做任何事情。您没有将任何Calendar
字段设置为用户选择日期的日期。您只是输出在DatePickerDialog侦听器触发之前存在的Calendar
字段。
我会这样做:
DatePickerDialog.OnDateSetListener mDateSetListener = new DatePickerDialog.OnDateSetListener() {
public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
calendar.set(Calendar.YEAR, year);
calendar.set(Calendar.MONTH, monthOfYear);
calendar.set(Calendar.DAY_OF_MONTH, dayOfMonth);
et_cal.setText("" + dayOfMonth + " - " + monthOfYear+1 + " - " + year);
}
};