我有一个模型类" JobPostBean"我在另一个模型类中启动并使用第二个模型类添加数据。我想清除任何保存在" JobPostBean"类。有没有办法在" JobPostBean"中清除它?类或在第二个模型类中初始化?我宁愿使用单一方法清除它,而不是设置" JobPostBean"中的每一项。 class为null。
public class BidNextJobDataModel {
private static BidNextJobDataModel ourInstance = new BidNextJobDataModel();
public static BidNextJobDataModel getInstance() {
return ourInstance;
}
private BidNextJobDataModel() {
}
public UserBean userBean;
// Here I initialised the class
public JobPostBean jobPostBean = new JobPostBean();
public ArrayList<FilterModel> filterModelArrayList = new ArrayList<FilterModel>();
public ArrayList<FilterModel> notificationModelArrayList = new ArrayList<FilterModel>();
public ArrayList<FilterModel> chooseCategoryArrayList = new ArrayList<FilterModel>();
public ArrayList<JobsBean> jobsBeanArrayList = new ArrayList<JobsBean>();
}
&#13;
public class JobPostBean {
private String jobtype="";
private String days="";
private String hour="";
private String title="";
private String category="";
private String categorytxt="";
private String description="";
private String price="";
private String duration="";
private String is_certified="";
private String is_insure="";
private String is_experience="";
private String address="";
private String name="";
private String image="";
private String date="";
private String pricetype="";
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getImage() {
return image;
}
public void setImage(String image) {
this.image = image;
}
public String getDate() {
return date;
}
public void setDate(String date) {
this.date = date;
}
public String getJobtype() {
return jobtype;
}
public void setJobtype(String jobtype) {
this.jobtype = jobtype;
}
public String getDays() {
return days;
}
public void setDays(String days) {
this.days = days;
}
public String getHour() {
return hour;
}
public void setHour(String hour) {
this.hour = hour;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getCategory() {
return category;
}
public void setCategory(String category) {
this.category = category;
}
public String getCategorytxt() {
return categorytxt;
}
public void setCategorytxt(String categorytxt) {
this.categorytxt = categorytxt;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getPrice() {
return price;
}
public void setPrice(String price) {
this.price = price;
}
public String getDuration() {
return duration;
}
public void setDuration(String duration) {
this.duration = duration;
}
public String getIs_certified() {
return is_certified;
}
public void setIs_certified(String is_certified) {
this.is_certified = is_certified;
}
public String getIs_insure() {
return is_insure;
}
public void setIs_insure(String is_insure) {
this.is_insure = is_insure;
}
public String getIs_experience() {
return is_experience;
}
public void setIs_experience(String is_experience) {
this.is_experience = is_experience;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
public String getPricetype() {
return pricetype;
}
public void setPricetype(String pricetype) {
this.pricetype = pricetype;
}
}
&#13;
答案 0 :(得分:1)
public ArrayList<JobPostBean > al_JobPostBean = new ArrayList<JobPostBean >(); // Declare as global
首先在ArrayList中保存数据。如果要删除所有数据,则可以清除 ArrayList
al_JobPostBean.clear();
clear()方法删除了ArrayList的所有元素。