如果單擊下一個按鈕,它的資料應該轉到 formattedDate 我已經嘗試了幾次,但它一直給我一個錯誤。
next.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// Perform action on click
Calendar c = Calendar.getInstance();
c.add(Calendar.DATE, 1);
System.out.println("Current time => " c.getTime());
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
String formattedDate = df.format(c.getTime());
textView.setText(formattedDate);
post.recipe_time = formattedDate;
}
});
這個格式化日期錯誤如何清除
private void requestHomeData2() {
ApiInterface apiInterface =
RestAdapter.createAPI(sharedPref.getApiUrl());
callbackCall2 =
apiInterface.getDate(formattedDate,AppConfig.REST_API_KEY);
this.callbackCall2.enqueue(new Callback<Callbackdate>() {
public void onResponse(Call<Callbackdate> call,
Response<Callbackdate> response) {
Callbackdate responseHome = response.body();
if (responseHome == null || !responseHome.status.equals("ok")) {
onFailRequest();
return;
}
displayData2(responseHome);
swipeProgress(false);
lyt_main_content.setVisibility(View.VISIBLE);
}
public void onFailure(Call<Callbackdate> call, Throwable th) {
Log.e("onFailure", th.getMessage());
if (!call.isCanceled()) {
onFailRequest();
}
}
});
}
uj5u.com熱心網友回復:
將您的String formattedDate變數設定為全域變數并將其初始化為,然后在您的下一個按鈕單擊中String formattedDate = ""分配值,然后在您需要的任何地方呼叫。formattedDate = df.format(c.getTime());requestHomeData2
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/536363.html
標籤:安卓应用程序接口日历
