【发布时间】:2020-11-03 07:23:40
【问题描述】:
这已经困扰了我一段时间,因为我无法完全理解这些论点是如何工作的。 你能帮我弄清楚我应该提出什么论据吗? 我正在尝试从另一个类中提取我存储的变量。所以我创建了一个创建实例并从该类调用变量的方法。 但是当我尝试调用它要求参数的方法时
这是我的代码,我删除了我认为不相关的代码。
我存储变量的源类:
public class UserProfile {
private int id;
private String lname, fname, mname, desig, employee_id;
private String profileImage;
public UserProfile(int id, String lname, String fname, String mname, String desig, String employee_id, String profileImage) {
this.id = id;
this.lname = lname;
this.fname = fname;
this.mname = mname;
this.desig = desig;
this.employee_id = employee_id;
this.profileImage = profileImage;
}
public int getId() {
return id;
}
public String getLname() {
return lname;
}
public String getFname() {
return fname;
}
public String getMname() {
return mname;
}
public String getDesig() {
return desig;
}
public String getEmployee_id() {
return employee_id;
}
public String getProfileImage() {
return profileImage;
}
}
我调用我的变量的班级:
public class TicketActivity extends AppCompatActivity implements AdapterView.OnItemSelectedListener {
Spinner spnrViolations, spnrDLtype;
TextView tvViolation1, tvViolation2, tvViolation3, tvViolation4, tvViolation5;
ImageButton clearV1, clearV2, clearV3, clearV4, clearV5;
TextView officerName, officerID, currentDate;
String violation1TV, violation2TV, violation3TV, violation4TV, violation5TV;
String clear ="Empty";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_ticket);
officerName = (TextView)findViewById(R.id.tv_ticket_area_officerName);
loadUser(); //<<<--------- it asks here for an argument that i dont know what to put :(
} //OnCreate END
private void loadUser(UserProfile userProfile) {
String fname, mname, lname;
fname = userProfile.getFname();
mname = userProfile.getMname();
lname = userProfile.getLname();
String fullname = fname + " " + mname + " " + lname;
officerName.setText(fullname);
}
} ////// THIS IS THE END ////////// ------------------------------------>>>>>>>>>>>>>>>>>>>>>>>>
【问题讨论】:
标签: java android-studio variables methods