如何在房产中改造1.9?

时间:2016-05-22 14:06:19

标签: android json retrofit

< p>如何在< code>(“名称”:“AccountManager”)< / code>中使用改装?性< / p为H. < pre>< code> [{     “ID”:3065,     “UserName”:“测试”,     “电子邮件”:“测试”,     “密码”:“测试”,     “SkypeID”:“测试”,     “GoogleHangout”:“测试”,     “无效”:错误,     “HasHoursRegistered”:false,     “CreatedBy”:null,     “EditedBy”:null,     “WebRole”:null,     “ProjectsDtos”:null,     “RegHoursDtos”:null,     “CustomersDtos”:null,     “RolesDtos”:\ [       {         “身份证”:1,         “名称”:“AccountManager”,         “价格”:null,         “用户”:null,         “UsersRolesProjects”:null       }     \],     “UsersRolesProjectsDtos”:null   } ] < /代码>< /预> < p>< img src =“https://i.stack.imgur.com/NsLLX.jpg”alt =“Image”>< / p>

2 个答案:

答案 0 :(得分:0)

你需要创建一个对象来处理响应,在这个对象中,你需要一个对象列表RolesDtos(因为是一个对象数组)

public class RolesDtos{
  int ID;
  String Name;    
  String prices;
  String Users;
  ...
  setters and getters
}

public class ResponseObject{
  int ID;
  String userName;    
  String email;
  String password;
  String skypeId;
  ...
  List<RolesDtos> rolesDtos; // <- here 
  ...
  setters and getters
}

要获得"Name": "AccountManager",您必须执行以下操作:

ResponseObject responseObject = new ResponseObject();
responseObject.getRolesDtos().get(0).getName(); 

get(0)是数组的位置,因此,您必须迭代数组。现在在请求中你必须做这样的事情:

@GET("url")
Call<ResponseObject> theRequest(...)

我希望这可以帮到你

答案 1 :(得分:0)

       How i can set here the  "Name": "AccountManager" property?  
 User user = getItem(position);


                if (user != null) {
                TextView tvUserId = (TextView) v.findViewById(R.id.user_id);
                TextView tvUserName = (TextView) v.findViewById(R.id.user_name);
                TextView tvEmail=(TextView)v.findViewById(R.id.email);
                TextView tvRole=(TextView)v.findViewById(R.id.userRole);

                tvUserId.setText( Integer.toString(user.ID));
                tvUserName.setText(user.UserName);
                tvEmail.setText(user.Email);
              //  tvRole.setText(user.getRolesDtos().toArray(1));