我正在尝试制作一个将天文表小部件用作国际象棋时钟的应用。我的目的是让其中一个功能自动重置两个时钟,并使用Google Sheets API将四条信息上载到Google Sheets,包括玩家名称和各自的时间安排。
我收到的错误是:
预期参数:
java ... google.api.client.util.Objects>
实际参数:
Arrays.asList(value)(java.util.List)
Arrays.asList(elapsedMillis)(java.util.List)
Arrays.asList(value1)(java.util.List)
Arrays.asList(elapsedMillis2)(java.util.List)
我不确定如何解决此问题。由于错误在此特定部分中显示,因此我尝试将Objects从字符串更改为其他内容无济于事:
ValueRange body = new ValueRange()
.setValues(Arrays.<List<Objects>>asList(
Arrays.asList(value),
Arrays.asList(elapsedMillis),
Arrays.asList(value1),
Arrays.asList(elapsedMillis2)));
完整功能如下:
public void resetChronometer(View v) {
chronometer.setBase(SystemClock.elapsedRealtime());
pauseOffset = 0;
chronometer2.setBase(SystemClock.elapsedRealtime());
pauseOffset2 = 0;
class SheetsExample {
public void main(String args[]) throws IOException, GeneralSecurityException {
String spreadsheetId = "SPREADSHEET_ID";
String range = "A2:D2";
String valueInputOption = "RAW";
ValueRange requestBody = new ValueRange();
Sheets sheetsService = createSheetsService();
Sheets.Spreadsheets.Values.Update request =
sheetsService.spreadsheets().values().update(spreadsheetId, range, requestBody);
request.setValueInputOption(valueInputOption);
UpdateValuesResponse response = request.execute();
System.out.println(response);
Sheets service = null;
ValueRange body = new ValueRange()
.setValues(Arrays.<List<Objects>>asList(
Arrays.asList(value),
Arrays.asList(elapsedMillis),
Arrays.asList(value1),
Arrays.asList(elapsedMillis2)));
UpdateValuesResponse result =
service.spreadsheets().values().update(spreadsheetId, range, body)
.update(spreadsheetId, "A1", body)
.setValueInputOption("RAW")
.execute();
System.out.printf("%d cells updated.", result.getUpdatedCells());
}
public Sheets createSheetsService() throws IOException, GeneralSecurityException {
HttpTransport httpTransport = GoogleNetHttpTransport.newTrustedTransport();
JsonFactory jsonFactory = JacksonFactory.getDefaultInstance();
GoogleCredential credential = null;
return new Sheets.Builder(httpTransport, jsonFactory, credential)
.setApplicationName("Warhammer Mate")
.build();
}
}
}
EditText text = (EditText) findViewById(R.id.editText);
EditText text1 = (EditText) findViewById(R.id.editText2);
String value = text.getText().toString();
String value1 = text1.getText().toString();
long elapsedMillis = SystemClock.elapsedRealtime() - chronometer.getBase();
long elapsedMillis2 = SystemClock.elapsedRealtime() - chronometer2.getBase();
}