【发布时间】:2021-11-17 08:22:25
【问题描述】:
这是删除数据的代码
@Override
public void onClick(View v) {
if (findViewById(R.id.btnDelete)==v){
restService.getService().deleteEmpById(_Student_Id, new Callback<AC_Daily_Line>() {
@Override
public void success(AC_Daily_Line spsTrans, Response response) {
Toast.makeText(AttendanceDelete.this, "Employee Record Deleted", Toast.LENGTH_LONG).show();
}
@Override
public void failure(RetrofitError error) {
Toast.makeText(AttendanceDelete.this, error.getMessage().toString(), Toast.LENGTH_LONG).show();
}
});
这是 JSON 数据
{"ID":2603,"AC_ID":"210924-0828","Emp_ID":"123456789","Att_Date":"2021-09-24T08:50:00"}
这是我的数据类
public class AC_Daily_Line {
public int ID;
public String AC_ID;
public String Emp_ID;
public String Att_Date;
}
这是我的 Web API 调用路径
@DELETE("/api/AC_Daily_Line/{id}")
public void deleteEmpById(@Path("id") Integer id,Callback<AC_Daily_Line> callback);
【问题讨论】:
-
你的数据类/pojo类在哪里??
-
@UmeshYadav 哦,现在我已经更新了我的数据类
-
遵循最佳实践很有帮助,尤其是在命名约定方面。
Class names should be nouns, in mixed case with the first letter of each internal word capitalized. Try to keep your class names simple and descriptive. Use whole words-avoid acronyms and abbreviations (unless the abbreviation is much more widely used than the long form, such as URL or HTML).。来自:oracle.com/java/technologies/javase/…